sp; <Button
android:layout_span="2"
android:text="Button5"
/>
</TableRow>
</TableLayout>
4.相对布局
相对布局是按照组件之间的相对位置来布局,比如在某个组件的左边,右边,上面和下面等。
简单的例子
①效果图:
② 核心代码:
main.xml
- <?xml version="1.0" encoding="utf-8"?>
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:padding="10px"
- >
- <TextView
- android:id="@+id/tev1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginBottom="30dp"
- android:text="Please Type Here:"
- />
- <EditText
- android:id="@+id/tx1"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/tev1"
- />
- <Button
- android:id="@+id/btn1"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:layout_below="@id/tx1"
- android:layout_alignParentRight="true"
- android:text="确定"
- />
- <Button
- android:id="@+id/btn2"
-
|