天天育儿网,内容丰富有趣,生活中的好帮手!
天天育儿网 > Android 布局之线性布局 相对布局 表格布局 帧布局

Android 布局之线性布局 相对布局 表格布局 帧布局

时间:2018-09-15 16:53:23

相关推荐

Android 布局之线性布局 相对布局 表格布局 帧布局

1、LinearLayout(线性布局)

[html]view plaincopy

<?xmlversion="1.0"encoding="utf-8"?>

<LinearLayoutxmlns:android="/apk/res/android"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:orientation="vertical">

<TextView

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="@string/mobile"/>

<EditText

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:id="@+id/mobile"/>

<Button

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="@string/button"

android:id="@+id/button"/>

<CheckBox

android:layout_width="wrap_content"

android:layout_height="wrap_content"/>

</LinearLayout>

2、RelativeLayout(相对布局)

[html]view plaincopy

<?xmlversion="1.0"encoding="utf-8"?>

<LinearLayoutxmlns:android="/apk/res/android"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:orientation="vertical">

<RelativeLayout

android:layout_width="fill_parent"

android:layout_height="wrap_content">

<TextView

android:layout_width="100dp"

android:layout_height="wrap_content"

android:text="@string/number"

android:id="@+id/numberlabel"/>

<EditText

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:id="@+id/number"

android:layout_toRightOf="@id/numberlabel"

android:layout_alignTop="@id/numberlabel"

android:layout_marginLeft="5dp"/>

</RelativeLayout>

<TextView

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="@string/content"/>

<EditText

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:minLines="3"

android:maxLines="3"

android:id="@+id/content"/>

<Button

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="@string/button"

android:id="@+id/button"/>

</LinearLayout>

3、TableLayout(表格布局两行两列)

[html]view plaincopy

<?xmlversion="1.0"encoding="utf-8"?>

<TableLayoutxmlns:android="/apk/res/android"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

Android:stretchColumns="1">

<TableRow>

<TextView

android:text="@string/table_lable1"

android:padding="3dip"/>

<TextView

android:text="@string/table_lable2"

android:gravity="right"

android:padding="3dip"/>

</TableRow>

<TableRow>

<TextView

android:text="@string/table_lable1"

android:padding="3dip"/>

<TextView

android:text="@string/table_lable2"

android:gravity="right"

android:padding="3dip"/>

</TableRow>

</TableLayout>

4、FrameLayout(帧布局)显示控件会进行叠加,后者会叠加在前者之上

[html]view plaincopy

<?xmlversion="1.0"encoding="utf-8"?>

<FrameLayoutxmlns:android="/apk/res/android"

android:layout_width="fill_parent"

android:layout_height="fill_parent">

<ImageView

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:src="@drawable/movie"/>

<ImageView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:src="@drawable/play"

android:layout_gravity="center"/>

</FrameLayout>

如果觉得《Android 布局之线性布局 相对布局 表格布局 帧布局》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。