Android学习笔记02
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的更多相关文章
- 零基础Android学习笔记-02 安卓程序生命周期
一个安卓程序生命周期会经历7中状态,并不一定是每次都全部经历.Create,Start,ReStart,Pause,Resume,Stop,Destory. 重载方法,用helloWorld程序去体验 ...
- Android学习笔记(一)
目录 Android学习笔记(一) 一.JDK.Android SDK 二.部分项目结构 三.字符串引用 四.外层build.gradle详解 五.app->build.gradle详解 六.日 ...
- 软件测试之loadrunner学习笔记-02集合点
loadrunner学习笔记-02集合点 集合点函数可以帮助我们生成有效可控的并发操作.虽然在Controller中多用户负载的Vuser是一起开始运行脚本的,但是由于计算机的串行处理机制,脚本的运行 ...
- Android 学习笔记之Volley(七)实现Json数据加载和解析...
学习内容: 1.使用Volley实现异步加载Json数据... Volley的第二大请求就是通过发送请求异步实现Json数据信息的加载,加载Json数据有两种方式,一种是通过获取Json对象,然后 ...
- Android学习笔记进阶之在图片上涂鸦(能清屏)
Android学习笔记进阶之在图片上涂鸦(能清屏) 2013-11-19 10:52 117人阅读 评论(0) 收藏 举报 HandWritingActivity.java package xiaos ...
- android学习笔记36——使用原始XML文件
XML文件 android中使用XML文件,需要开发者手动创建res/xml文件夹. 实例如下: book.xml==> <?xml version="1.0" enc ...
- Android学习笔记之JSON数据解析
转载:Android学习笔记44:JSON数据解析 JSON(JavaScript Object Notation)是一种轻量级的数据交换格式,采用完全独立于语言的文本格式,为Web应用开发提供了一种 ...
- udacity android 学习笔记: lesson 4 part b
udacity android 学习笔记: lesson 4 part b 作者:干货店打杂的 /titer1 /Archimedes 出处:https://code.csdn.net/titer1 ...
- 机器学习实战(Machine Learning in Action)学习笔记————02.k-邻近算法(KNN)
机器学习实战(Machine Learning in Action)学习笔记————02.k-邻近算法(KNN) 关键字:邻近算法(kNN: k Nearest Neighbors).python.源 ...
随机推荐
- radhat 6.4/centos 6.4 下编译安装 最新ruby 2.1.5
#安装编译环境 yum groupinstall "Development tools" 或者 yum install gcc gcc-c++ gcc-g77 flex bison ...
- Windows Kernel Security Training Courses
http://www.codemachine.com/courses.html#kerdbg Windows Kernel Internals for Security Researchers Thi ...
- spring 初始化时注入bean实现listener的方法
两种方法: 1.实现ApplicationListener<ContextRefreshedEvent>的onApplicationEvent(ContextRefreshedEvent ...
- Linux下printf格式符%d、%lld、%llx、%u等【转自CSDN博客】
来源:http://blog.csdn.net/anycell/article/details/6966520 %d 有符号32位整数 %lld 有符号64位证书 %llx有符号64位16进制整数 % ...
- 浅析Struts1和Struts2的Action线程安全问题 转
浅析Struts1和Struts2的Action线程安全问题 转 http://blog.csdn.net/virgoboy2004/article/details/5876133 [问题描述]最近 ...
- String的compareTo()方法返回值
compareTo()的返回值是整型,它是先比较对应字符的大小(ASCII码顺序),如果第一个字符和参数的第一个字符不等,结束比较,返回他们之间的 差值,如果第一个字符和参数的第一个字符相等,则以第二 ...
- javascript中单体模式的实现
单体模式作为一种软件开发模式在众多面向对象语言中得到了广泛的使用,在javascript中,单体模式也是使用非常广泛的,但是由于javascript语言拥有其独特的面向对象方式,导致其和一些传统面向对 ...
- linux 命令之系统活动报告sar
打开自己的CentOS,敲入“sar”,表示很失望: [root@localhost ~]# sar bash: sar: command not found 竟然没有安装,不过还好linux下安装还 ...
- HackerRank "Dorsey Thief"
A variation to 0-1 Knapsack. (No Python code got fully AC. Python is too slow for this problem) #inc ...
- Redis集群方案介绍
由于Redis出众的性能,其在众多的移动互联网企业中得到广泛的应用.Redis在3.0版本前只支持单实例模式,虽然现在的服务器内存可以到100GB.200GB的规模,但是单实例模式限制了Redis没法 ...