第八节(Activity布局初步一)
一、LinearLayout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<!--
android:orientation="vertical"- -指定控件排列方向
android:layout_width="fill_parent"
android:layout_height="fill_parent"
-->
<!--
android:id="@+id/btn_1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="第2行"
android:gravity="center"- -指定控件的基本位置比如居中、居右等位置
android:textSize="20pt"- -指定控件当中文本字体大小
android:background="#aa0000"- -指定控件背景色,使用RGB命名法
android:padding....- -指定控件内容的边距
android:layout_weight="2"- -指定控件在布局中占用屏幕的比例
android:singleLine="true"- -指定控件是的内容是否在同一行中展示
-->
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
android:layout_weight="5"
/>
<Button
android:id="@+id/btn_1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="第2行第2行第2行第2行第2行第2行第2行第2行第2行第2行第2行第2行第2行第2行"
android:gravity="top"
android:textSize="20pt"
android:background="#aa0000"
android:paddingLeft="10dip"
android:paddingTop="1dip"
android:paddingRight="30dip"
android:paddingBottom="40dip"
android:layout_weight="1"
android:singleLine="true"
/>
</LinearLayout>二、TableLayout
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="0"
>
<!-- android:stretchColumns="0"如果不能撑满窗口,拉伸第0列填满窗口 -->
<TableRow>
<TextView
android:text="column1"
android:padding="5dip"
android:background="#aa0000"
/>
<TextView
android:text="column2"
android:padding="5dip"
android:background="#0000aa"
android:layout_gravity="center_vertical"
/>
<TextView
android:text="column3"
android:padding="5dip"
android:background="#00aa00"
/>
</TableRow>
<TableRow>
<TextView
android:text="column1"
android:padding="5dip"
/>
<TextView
android:text="column2"
android:padding="5dip"
/>
<TextView
android:text="column3"
android:padding="5dip"
/>
</TableRow>
</TableLayout> 相关推荐
xfcyhades 2020-11-20
Michael 2020-11-03
业余架构师 2020-10-09
OuNuo0 2020-09-29
moses 2020-09-22
Angelia 2020-09-11
qinxu 2020-09-10
刘炳昭 2020-09-10
Nostalgiachild 2020-09-07
Nostalgiachild 2020-08-17
leavesC 2020-08-14
一青年 2020-08-13
AndroidAiStudy 2020-08-07
ydc0 2020-07-30
绿豆饼 2020-07-28