要实现这种效果,
-
LinearLayout的嵌套实现 2.使用RelativeLayout
-
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
<?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>
-
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
<?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"
在指定组件下边
-->
本文转自 matengbing 51CTO博客,原文链接:http://blog.51cto.com/matengbing/1880754