android--布局

布局

View类是android系统平台上用户界面的基本单元。

View类的一些子类被统称为widgets

Linearyout:线性布局(在该标签下根据其orientation属性的值来决定是按行或者按列逐个显示)

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

"http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical" >其属性“orientation”指定子元素排列方式,其中指定为vertical是子元素垂直排列,每个子元素会占独立的一行,horizontal代表子元素水平排列,每个资源元素会占独立一列

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="@string/text"

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

android:layout_width="fill_parent"

android:layout_height="wrap_content">

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginLeft="250dp"

android:text="@string/cancle"

android:layout_alignParentRight="true"/>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginLeft="200dp"

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

Tablelayout:表格布局

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

"http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:stretchColumns="*">

android:layout_width="wrap_content"

android:layout_height="wrap_content"

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

android:layout_width="wrap_content"

android:layout_height="wrap_content"

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

android:layout_width="wrap_content"

android:layout_height="wrap_content"

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

android:layout_width="wrap_content"

android:layout_height="wrap_content"

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

android:layout_width="wrap_content"

android:layout_height="wrap_content"

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

android:layout_width="wrap_content"

android:layout_height="wrap_content"

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

注:定义一个行

定义一个单元的内容

Android:stretchColumns=“0,1,2”该属性指定每行都由第“0,1,2,”列占满空白空间。

Gravity指定文字对齐方式

Padding指定视图与视图内容的空隙,单位为像素。

Relativelayout:相对布局

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

"http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="match_parent" >

你可能感兴趣的:(移动开发)