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. ExpressRoute

    Extending Your Network to Microsoft Azure Using ExpressRoute https://channel9.msdn.com/events/TechEd ...

  2. 最大化 AIX 上的 Java 性能,第 5 部分: 参考资料和结论

    http://www.ibm.com/developerworks/cn/aix/library/es-Javaperf/es-Javaperf5.html 最大化 AIX 上的 Java 性能,第 ...

  3. Visual Studio 2013 Web开发、新增功能:“Browser Link”

    微软正式发布Visual Studio 2013 RTM版,微软还发布了Visual Studio 2013的最终版本..NET 4.5.1以及Team Foundation Server 2013. ...

  4. shell脚本实例-系统监控

    shell脚本监控网站并实现邮件.短信报警shell进程监控脚本(发送邮件报警)Shell脚本监控服务器在线状态和邮件报警的方法 http://www.jbxue.com/jb/shell/ 11. ...

  5. unity, LoadLevelAdditive到帧末才完成

    Application.LoadLevelAdditive文档中说: LoadLevel and LoadLevelAdditive don't happen immediately - a new  ...

  6. php编程安全指南

    php编程安全指南1.一般 1)lamp系统安全设置 2)php.ini安全设置 3)使用MVC框架 2.数据传输 1)在$_GET的$_POST,$_COOKIE,和$_REQUEST中,消毒和验证 ...

  7. js给定时器调用传递参数

    给定时器调用传递参数 无论是window.setTimeout 还是window.setInterval,在使用函数名作为调用句柄时都不 能带参数,而在许多场合必需要带参数,这就需要想方法解决.例如对 ...

  8. fiddler filter 过滤css 图片等

    找到 request header->Show only if yrl contains: REGEX:(?insx)/[^\?/]*\.(css|ico|jpg|png|gif|bmp|wav ...

  9. Spring的依赖注入(DI)三种方式

    Spring依赖注入(DI)的三种方式,分别为: 1.  接口注入 2.  Setter方法注入 3.  构造方法注入 下面介绍一下这三种依赖注入在Spring中是怎么样实现的. 首先我们需要以下几个 ...

  10. The word is not correctly spelled问题解决

    今天在做Ant/Xdoclet辅助生成hibernate实体映射文件时,eclipse出现了极其让我郁闷的错误,"The word is not correctly spelled" ...