布局介绍:
Linearlayout(线性布局)、RelativetLayout(相对布局)、
TableLayout(表格布局)、FrameLayout(帧布局)
padding(内间距)指的是控件和周边四个方向的距离。
@android:drawable/editbox_background用来指定系统的android的文件夹的R文件的内容。
在设置大的背景的时候可以选择自己喜欢的照片就行显示。
作为根元素肯定有一个命名空间。
在布局文件中要想设置布局的背景直接输入#加六位RGB值就可以了。
padding指的是该控件离周边四条边的距离都是它设置的值。也就是内 间距。
在使用背景图片的时候可以使用开发者自己放进去的背景资源,也可以使用安卓系统自带的资源,使用的时候是这样使用的:@android:drawable:/editbox_background
安卓自带的drawable里面的资源。
layout_below在什么什么的下面。
alignParentRight对齐父元素的右边。
marginLeft控件与控件之间的距离。
toLeftOf在什么什么的左边。
alignTop和什么什么的上边对齐。
relativelayout事例
<?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" >
<RelativeLayout
android:id="@+id/relaylayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<TextView
android:id="@+id/textNum"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:height="35dp"
android:text="请输入手机号"
android:textSize="20sp" />
<EditText
android:id="@+id/editNum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/textNum"
android:layout_alignParentRight="true"
android:hint="18700000000" />
</RelativeLayout>
<TextView
android:id="@+id/textContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/relaylayout"
android:textSize="20sp"
android:text="请输入短信内容" />
<EditText
android:id="@+id/editContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/textContent"
android:minLines="3" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/editContent"
android:digits="@+id/btnSend"
android:textSize="20sp"
android:text="发送短信" />
</RelativeLayout>
tablelayout事例
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="1" >
<TableRow>
<TextView
android:padding="3dp"
android:text="1" />
<TextView
android:padding="3dp"
android:text="2" />
</TableRow>
<TableRow>
<TextView
android:padding="3dp"
android:text="3" />
<TextView
android:padding="3dp"
android:text="4" />
</TableRow>
</TableLayout>
FrameLayout简单介绍
它们之间是叠加的关系。
是一层上面叠加一层,第二层可以盖住第一层。
例如在看电视看电影的时候上面的暂停按钮就是叠加在电视或者电影画面上的。
做游戏的时候也会用到,几个画面叠加到了一起。
Linearlayout(线性布局)、RelativetLayout(相对布局)、
TableLayout(表格布局)、FrameLayout(帧布局)
padding(内间距)指的是控件和周边四个方向的距离。
@android:drawable/editbox_background用来指定系统的android的文件夹的R文件的内容。
在设置大的背景的时候可以选择自己喜欢的照片就行显示。
作为根元素肯定有一个命名空间。
在布局文件中要想设置布局的背景直接输入#加六位RGB值就可以了。
padding指的是该控件离周边四条边的距离都是它设置的值。也就是内 间距。
在使用背景图片的时候可以使用开发者自己放进去的背景资源,也可以使用安卓系统自带的资源,使用的时候是这样使用的:@android:drawable:/editbox_background
安卓自带的drawable里面的资源。
layout_below在什么什么的下面。
alignParentRight对齐父元素的右边。
marginLeft控件与控件之间的距离。
toLeftOf在什么什么的左边。
alignTop和什么什么的上边对齐。
relativelayout事例
<?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" >
<RelativeLayout
android:id="@+id/relaylayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<TextView
android:id="@+id/textNum"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:height="35dp"
android:text="请输入手机号"
android:textSize="20sp" />
<EditText
android:id="@+id/editNum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/textNum"
android:layout_alignParentRight="true"
android:hint="18700000000" />
</RelativeLayout>
<TextView
android:id="@+id/textContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/relaylayout"
android:textSize="20sp"
android:text="请输入短信内容" />
<EditText
android:id="@+id/editContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/textContent"
android:minLines="3" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/editContent"
android:digits="@+id/btnSend"
android:textSize="20sp"
android:text="发送短信" />
</RelativeLayout>
tablelayout事例
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="1" >
<TableRow>
<TextView
android:padding="3dp"
android:text="1" />
<TextView
android:padding="3dp"
android:text="2" />
</TableRow>
<TableRow>
<TextView
android:padding="3dp"
android:text="3" />
<TextView
android:padding="3dp"
android:text="4" />
</TableRow>
</TableLayout>
FrameLayout简单介绍
它们之间是叠加的关系。
是一层上面叠加一层,第二层可以盖住第一层。
例如在看电视看电影的时候上面的暂停按钮就是叠加在电视或者电影画面上的。
做游戏的时候也会用到,几个画面叠加到了一起。