1.线性布局LinearLayout

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" > <TextView
android:id="@+id/firstText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" //控件所占的比例,
android:background="#aa0000"
android:gravity="center_vertical"
android:paddingBottom="40dip"
android:paddingLeft="10dip"
android:paddingRight="30dip"
android:paddingTop="20dip"
android:singleLine="false" //为true则不换行显示
android:text="第一行第一行第一行第一行第一行第一行第一行第一行第一行第一行第一行第一行"
android:textSize="35pt" >
</TextView> <TextView
android:id="@+id/secondText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#0000aa"
android:gravity="center_vertical"
android:text="第二行"
android:textSize="15pt" >
</TextView> </LinearLayout>

2.表格布局TableLayout

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="0" //宽度不够的时候,第0列变宽 > <TableRow> <TextView
android:padding="3dip"
android:background="#aa0000"
android:text="@string/row1_column1" >
</TextView> <TextView
android:padding="3dip"
android:background="#00aa00"
android:text="@string/row1_column1"
android:gravity="center_horizontal">
</TextView> <TextView
android:gravity="right"
android:padding="3dip"
android:background="#0000aa"
android:text="@string/row1_column2" />
</TableRow> <TableRow> <TextView
android:padding="3dip"
android:text="@string/row2_column1" /> <TextView
android:gravity="right"
android:padding="3dip"
android:text="@string/row2_column2" />
</TableRow> </TableLayout>

3.嵌套布局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#123"
android:orientation="vertical"
tools:context="com.example.mars_0700_layout03.MainActivity"
tools:ignore="MergeRootFrame" > <LinearLayout
android:id="@+id/container1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#456"
android:orientation="horizontal" > <TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#110987"
android:text="123" /> <TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#228932"
android:text="456" /> <TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#331849"
android:text="789" /> <TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#449843"
android:text="abc" />
</LinearLayout> <LinearLayout
android:id="@+id/container2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#789"
android:orientation="vertical" > <TableLayout
android:id="@+id/container3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="0"
> <TableRow> <TextView
android:background="#198374"
android:padding="3dip"
android:text="123" >
</TextView>
<TextView
android:background="#098754"
android:padding="3dip"
android:text="123" >
</TextView>
</TableRow> <TableRow>
<TextView
android:background="#128495"
android:padding="3dip"
android:text="123" >
</TextView>
<TextView
android:background="#098758"
android:padding="3dip"
android:text="123" >
</TextView>
</TableRow> <TableRow>
<TextView
android:background="#875694"
android:padding="3dip"
android:text="123" >
</TextView>
<TextView
android:background="#090000"
android:padding="3dip"
android:text="123" >
</TextView>
</TableRow>
</TableLayout>
</LinearLayout> </LinearLayout>

4.相对布局RelativeLayout

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10px"
tools:context="com.example.mars_0800_layout04.MainActivity"
tools:ignore="MergeRootFrame" > <TextView
android:id="@+id/label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Type here:" /> <EditText
android:id="@+id/entry"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/label"
android:background="@android:drawable/editbox_background" /> <Button
android:id="@+id/ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@id/entry"
android:layout_marginLeft="10px"
android:text="OK" /> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/ok"
android:layout_toLeftOf="@id/ok"
android:text="Cancel" /> </RelativeLayout>

android:layout_above 将该控件的底部至于给定ID的控件之上
android:layout_below 将该控件的顶部置于给定ID的控件之下
android:layout_toLeftOf将该控件的右边缘和给定ID的控件的左边缘对齐
android:layout_toRightOf将该控件的左边缘和给定ID的控件的右边缘对齐

android:layout_alignBaseline该控件的baseline和给定ID的控件的baseline对齐
android:layout_alignBottom将该控件的底部边缘与给定ID控件的低部边缘对齐
android:layout_alignLeft将该控件的左边缘与给定ID控件的左边缘对齐
android:layout_alignRight将该控件的右边缘与给定ID控件的右边缘对齐
android:layout_alignTop将给定控件的顶部边缘与给定ID控件的顶部对齐

android:alignParentBottom 如果该值为true,则将该控件的底部和父控件的底部对齐
android:layout_alignParentLeft 如果该值为true,则将该控件的左边与父控件的左边对齐
android:layout_alignParentRight 如果该值为true,则将该控件的右边与父控件的右边对齐
android:layout_alignParentTop 如果该值为true,则将空间的顶部与父控件的顶部对齐

android:layout_centerHorizontal 如果值为真,该控件将被置于水平方向的中央
android:layout_centerInParent 如果值为真,该控件将被置于父控件水平方向和垂直方向
android:layout_centerVertical 如果值为真,该控件将被置于垂直方向的中央

Android学习笔记02的更多相关文章

  1. 零基础Android学习笔记-02 安卓程序生命周期

    一个安卓程序生命周期会经历7中状态,并不一定是每次都全部经历.Create,Start,ReStart,Pause,Resume,Stop,Destory. 重载方法,用helloWorld程序去体验 ...

  2. Android学习笔记(一)

    目录 Android学习笔记(一) 一.JDK.Android SDK 二.部分项目结构 三.字符串引用 四.外层build.gradle详解 五.app->build.gradle详解 六.日 ...

  3. 软件测试之loadrunner学习笔记-02集合点

    loadrunner学习笔记-02集合点 集合点函数可以帮助我们生成有效可控的并发操作.虽然在Controller中多用户负载的Vuser是一起开始运行脚本的,但是由于计算机的串行处理机制,脚本的运行 ...

  4. Android 学习笔记之Volley(七)实现Json数据加载和解析...

    学习内容: 1.使用Volley实现异步加载Json数据...   Volley的第二大请求就是通过发送请求异步实现Json数据信息的加载,加载Json数据有两种方式,一种是通过获取Json对象,然后 ...

  5. Android学习笔记进阶之在图片上涂鸦(能清屏)

    Android学习笔记进阶之在图片上涂鸦(能清屏) 2013-11-19 10:52 117人阅读 评论(0) 收藏 举报 HandWritingActivity.java package xiaos ...

  6. android学习笔记36——使用原始XML文件

    XML文件 android中使用XML文件,需要开发者手动创建res/xml文件夹. 实例如下: book.xml==> <?xml version="1.0" enc ...

  7. Android学习笔记之JSON数据解析

    转载:Android学习笔记44:JSON数据解析 JSON(JavaScript Object Notation)是一种轻量级的数据交换格式,采用完全独立于语言的文本格式,为Web应用开发提供了一种 ...

  8. udacity android 学习笔记: lesson 4 part b

    udacity android 学习笔记: lesson 4 part b 作者:干货店打杂的 /titer1 /Archimedes 出处:https://code.csdn.net/titer1 ...

  9. 机器学习实战(Machine Learning in Action)学习笔记————02.k-邻近算法(KNN)

    机器学习实战(Machine Learning in Action)学习笔记————02.k-邻近算法(KNN) 关键字:邻近算法(kNN: k Nearest Neighbors).python.源 ...

随机推荐

  1. 二十四种设计模式:组合模式(Composite Pattern)

    组合模式(Composite Pattern) 介绍将对象组合成树形结构以表示"部分-整体"的层次结构.它使得客户对单个对象和复合对象的使用具有一致性.示例有一个Message实体 ...

  2. 二十四种设计模式:原型模式(Prototype Pattern)

    原型模式(Prototype Pattern) 介绍用原型实例指定创建对象的种类,并且通过拷贝这个原型来创建新的对象.示例有一个Message实体类,现在要克隆它. MessageModel usin ...

  3. Create STATISTICS,UPDATE STATISTICS

    该命令在一张表或者索引了的视图上更新查询优化统计数字信息. 默认情况下, 查询优化器已经更新了必要的用来提高查询计划的统计信息; 在某些情况下, 你可以通过使用UPDATE STATISTICS 命令 ...

  4. shell之脚本练习

    脚本需求集合贴-自主开发的 对频繁执行的任务有编写脚本的价值 对单次执行的任务就用笨的,简单的办法 1.对asterisk写一个脚本 查日志 输入日期--能够输出对应日期的日志 输入多个条件--能够输 ...

  5. OpenJudge计算概论-求特殊自然数【枚举法】【将整数转成字符串】

    /*======================================================================== 求特殊自然数 总时间限制: 1000ms 内存限制 ...

  6. linux -samba

    yum install samba samba-client samba-swat samba-common-3.6.9-151.el6.x86_64 //主要提供samba服务器的设置文件与设置文件 ...

  7. 【转】php curl 伪造IP来源的实例代码

    curl发出请求的文件fake_ip.php: 代码 复制代码 代码如下: <?php $ch = curl_init(); $url = "http://localhost/targ ...

  8. Golang_test

    package main import ( "fmt" "time" ) func GetName() { //没事玩一下循环 for i := 0; i &l ...

  9. php自动转换pfx到pem和cer(dem格式)到pem

    经常做银行的支付接口,私钥一般都是pfx格式(私钥用来加密生成签名发送报文),公钥是cer格式(公钥用来验证返回报文里的签名).但是php里openssl只能用pem格式,每次转换都要用openssl ...

  10. jquery form表单序列号

    1.serialize()方法 格式:var data = $("form").serialize(); 功能:将表单内容序列化成一个字符串. 这样在ajax提交表单数据时,就不用 ...