2015-12-10 4 views
-3

Как я могу создать это Layout в android studio? Я пытаюсь написать некоторые коды, но я не могу это сделать. Спасибо за помощь. Должен ли я использовать LinearLayout или RelativeLayout или TableLayout для этого же просмотра для все устройства.Как создать этот экран в Android?

layout layout

http://i.imgur.com/EBd3CAo.png

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:weightSum="1" 
    android:background="#404040"> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" android:layout_height="59dp" 
     android:orientation="horizontal" 
     android:weightSum="1"> 

    <EditText 
     android:layout_width="198dp" 
     android:id="@+id/editText" 
     android:layout_above="@+id/tv1" 
     android:layout_marginBottom="31dp" 
     android:text="12345678901" 
     android:autoText="false" 
     android:elegantTextHeight="false" 
     android:maxLength="11" 
     android:singleLine="true" 
     android:background="#000000" 
     android:textColor="#a0a0a0" 
     android:inputType="number" 
     android:textSize="40dp" 
     android:textAlignment="center" 
     android:textStyle="bold" 
     android:layout_height="50dp" 
     android:layout_weight="0.45" /> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:text="tv1" 
      android:id="@+id/tv1" 
      android:layout_weight="0.36" 
      android:textColor="#55ff1c" 
      android:paddingLeft="10dp" /> 
    </LinearLayout> 

    <CheckBox 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="bla bla bla bla bla" 
     android:id="@+id/cbx1" 
     android:checked="false" 
     android:singleLine="true" 
     android:textSize="18dp" /> 

    <LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
     <ListView 
      android:layout_width="180dp" 
      android:layout_height="wrap_content" 
      android:id="@+id/listView" /> 
     <LinearLayout 
      android:orientation="vertical" 
      android:layout_width="180dp" 
      android:layout_height="wrap_content"> 
      <RadioGroup 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content"></RadioGroup> 
     </LinearLayout> 
    </LinearLayout> 
</LinearLayout> 
+1

Относительного расположением, было бы лучше. –

+0

как я могу это использовать? Я новичок на android. – lotomax

+0

Вы можете найти его, как использовать 'RelativeLayout'. –

ответ

2

Изменения Маржа/дополнение/размер шрифт/цвет в соответствии с требованиями

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#404040" 
    android:orientation="vertical" 
    android:weightSum="3"> 

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     > 

     <EditText 
      android:id="@+id/editText" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_margin="10dp" 
      android:layout_above="@+id/tv1" 
      android:autoText="false" 
      android:background="#000000" 
      android:elegantTextHeight="false" 
      android:inputType="number" 
      android:maxLength="11" 
      android:singleLine="true" 
      android:text="12345678901" 
      android:textAlignment="center" 
      android:textColor="#a0a0a0" 
      android:textSize="40dp" 
      android:textStyle="bold" /> 

     <TextView 
      android:id="@+id/tv1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:padding="5dp" 
      android:text="tv1" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:textColor="#55ff1c" /> 
    </LinearLayout> 

    <CheckBox 
     android:id="@+id/cbx1" 
     android:layout_margin="10dp" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:checked="false" 
     android:singleLine="true" 
     android:text="bla bla bla bla bla" 
     android:textSize="18dp" /> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_weight="2.8" 
     android:layout_margin="10dp" 
     android:layout_height="0dp" 
     android:orientation="horizontal"> 

     <ListView 
      android:id="@+id/listView" 
      android:layout_width="0dp" 
      android:layout_weight="1" 
      android:layout_height="wrap_content" /> 

     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_weight="1" 
      android:layout_height="wrap_content" 
      android:orientation="vertical"> 

      <RadioGroup 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="20dp"> 
       <RadioButton 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="RadioButton1"/> 
       <RadioButton 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:text="RadioButton2"/> 
      </RadioGroup> 
      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" 
       android:layout_marginTop="20dp"> 

       <TextView 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="1" 
        android:textSize="20sp" 
        android:text="Text View" /> 

       <TextView 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="1" 
        android:textSize="20sp" 
        android:text="Text View" /> 
      </LinearLayout> 

      <Button 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="20dp" 
       android:padding="5dp" 
       android:text="button" /> 
     </LinearLayout> 
    </LinearLayout> 
    <TextView 
     android:layout_gravity="bottom" 
     android:layout_width="match_parent" 
     android:layout_weight="0.2" 
     android:layout_margin="10dp" 
     android:layout_height="wrap_content" 
     android:text="Bottomtextview"/> 
</LinearLayout> 

Screenshot

+0

большое спасибо. – lotomax

1

Я сделал дизайн, как вам нужно. Но вам может потребоваться установить высоту и ширину самостоятельно. взгляните на приведенный ниже код.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal"> 

     <EditText 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="2" 
      android:hint="Edit Text" /> 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Text View" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <CheckBox 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Check Box" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:orientation="horizontal"> 

     <ListView 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" /> 

     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:orientation="vertical"> 

      <RadioGroup 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"> 

       <RadioButton 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:text="Radio Button" /> 

       <RadioButton 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:text="Radio Button" /> 
      </RadioGroup> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_weight="1" 
       android:orientation="horizontal"> 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center" 
        android:orientation="vertical"> 

        <LinearLayout 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:orientation="horizontal"> 

         <TextView 
          android:layout_width="0dp" 
          android:layout_height="wrap_content" 
          android:layout_weight="1" 
          android:text="Text View" 
          android:textSize="24sp" /> 

         <TextView 
          android:layout_width="0dp" 
          android:layout_height="wrap_content" 
          android:layout_gravity="bottom" 
          android:layout_weight="1" 
          android:text="Text View" /> 
        </LinearLayout> 

        <LinearLayout 
         android:layout_width="match_parent" 
         android:layout_height="10dp" /> 

        <Button 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="Button" 
         android:textSize="24sp" /> 
       </LinearLayout> 


      </LinearLayout> 

     </LinearLayout> 

    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="50dp" 
     android:gravity="center" 
     android:orientation="vertical"> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center" 
      android:text="Text View" 
      android:textSize="30sp" /> 
    </LinearLayout> 

</LinearLayout> 

Я разработал это по линейной схеме. надеюсь, это поможет вам.

+0

большое спасибо. – lotomax

Смежные вопросы