wKioL1hJCTrQbAorAAHeWdhDusU595.png-wh_50

要实现这种效果,

  1. LinearLayout的嵌套实现    2.使用RelativeLayout


  2. 1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    <?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:paddingLeft="10dp" 
         android:paddingRight="10dp" 
         >
         
     
         
         <EditText 
            android:id="@+id/EditText1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/reminder"
            />
          
          
         <LinearLayout 
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:orientation="horizontal"
             >
              <EditText 
            android:id="@+id/dates"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
             
            />
         
         <EditText 
            android:id="@+id/times"
            android:layout_width="100dp"
            android:layout_height="wrap_content"
               
             
            />
          
         </LinearLayout>
          
        
         <Button 
             android:id="@+id/button1"
             android:layout_width="96dp"
             android:layout_height="wrap_content"
             android:layout_gravity="right"
             android:text="提交"
             />
     
    </LinearLayout>


  3. 1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent" 
        android:paddingLeft="10dp"
        android:paddingRight="10dp"
        >
        <EditText 
            android:id="@+id/EditText1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:hint="@string/reminder"
            />
        <EditText 
            android:id="@+id/dates"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/EditText1"
            android:layout_alignParentLeft="true"    
            android:layout_toLeftOf="@+id/times" 
             
            />
         
         <EditText 
            android:id="@+id/times"
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:layout_below="@+id/EditText1"
            android:layout_alignParentRight="true"     
             
            />
          
         <Button 
             android:id="@+id/button1"
             android:layout_width="96dp"
             android:layout_height="wrap_content"
             android:layout_below="@id/times"
             android:layout_alignParentRight="true"
             android:text="提交"
             />
         
     
    </RelativeLayout>
    <!--   android:layout_alignParentLeft="true"    和父控件左对齐
    android:layout_toLeftOf="@+id/times" 在指定组件左边
    android:layout_below="@id/EditText1"   在指定组件下边
     -->