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. 使用rman中的duplicate复制数据库

    目标库和复制库环境: OS: Linux Red Hat AS 4 DB Version: 10.2.0.1   1.目标库和复制库信息 Rman 中的目标库(target database)指的是被 ...

  2. IE下必须点击一下页面空白的地方才可以激活onchange事件

    checkbox在IE下必须点击一下页面空白的地方才可以激活onchange事件. 解决办法把onchange换成onclick

  3. AngularJS 1.5.0-beta.2 and 1.4.8 have been released

    AngularJS 1.5.0-beta.2 With AngularJS 1.5.0-beta.2, we’ve improved the performance and flexibility o ...

  4. CentOS6.4系统启动失败故障排查

    转:http://www.centoscn.com/CentosBug/osbug/2014/1028/4011.html 操作系统启动失败如下图报错: 故障现象: 从图中可以看到,操作系统启动的过程 ...

  5. 可视化SNV安装

    以前也安装过非图形化的SVN SERVER,但大多都需要比较复杂的配置,而且操作不太友好,所以其拥有可视化功能就比较重要了. 好了,开始干活吧. 说明:测试机为开发爬虫用的服务器,配置不高 准备工作: ...

  6. hibernate的工作原理

    hibernate的工作原理1.Hibernate 的初始化.读取Hibernate 的配置信息-〉创建Session Factory1)创建Configeration类的实例.它的构造方法:将配置信 ...

  7. java file的一些方法

    file包下的一些方法:       File file = new File("d:\\", "tea.txt");         //文件名        ...

  8. C#实现数字字符串左补齐0的3种方法

    int n = 3; string s = n.ToString().PadLeft(4, '0'); //0003 s = string.Format("{0:d4}", n); ...

  9. BI案例:BI在连锁零售业应用(ZT)

    第一部分:连锁零售企业上BI的必要性. 目前国内的连锁零售行业的发展趋势,呈现出产业规模化,经营业态多样化,管理精细化的特点.所谓管理精细化就是"精耕细作搞管理,领先一步订系统". ...

  10. Android内核剖析读书笔记

    第16章 程序包管理 PackageManagerService類 PmS 目錄 16.1 包管理概述 16.2 packages.xml文件格式 16.3 包管理服務的啟動過程 16.4 應用程序的 ...