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.源 ...
随机推荐
- 拉动滚动条追加内容,无限延伸document高度 $(window).scroll(function(){if($(window).scrollTop() + $(window).height() == $(document).height()) { $("body").append(html) } })
$(document).ready(function() { // endless scrolling $(window).scroll(function() { if($(window).scrol ...
- 递归遍历多维数组(树数据结构)的超级简单方式,并且可以递归超过200层,摘自<<PHP精粹:编写高效PHP代码>>
<?php $array = array( "Hello", // Level 1 array( "World" // Level 2 ), array( ...
- createdb test时报global/pg_filenode.map不存在
实际上是存在的,看到说是ipv6占用了5432的端口号,看了一下的确是,将ipv6关闭重启系统即可. 下面是关闭ipv6的方法: 确认IPV6是否开启 在Linux下确认IPv6是否已经被启用,可以从 ...
- Linux 用户态和内核态
1.特权级特权级用来管理和控制程序执行.如Intel x86架构的CPU,有0~3四个特权级,0级最高,3级最低.硬件在执行每条指令时都会检查指令具有的特权级.硬件提供了特权级使用机制,对操作系统来说 ...
- 转载:javascript 拖拽排序,简洁示例备忘
转载自:http://blog.csdn.net/wang4978/article/details/6721157 <html> <head> <title>拖动行 ...
- 怎么用ABBYY打开PDF文档
我们日常工作中接触的文档大多都是PDF格式的,这种格式的文件需要借助工具才能打开,大家最熟悉的无非就是Adobe了,但你知道吗?除了Adobe,OCR文字识别软件也可以打开PDF文档,比如ABBYY ...
- 【转】ASP.NET Cookies简单应用 记住用户名和密码
不要试图给Password类型的TextBox赋值! 在asp.net中,不要试图给Password类型的TextBox控件赋值! 无论是在设计或是运行时,都不可以的. 猜测的原因是,password ...
- Mysql函数FIND_IN_SET()的使用方法
有了FIND_IN_SET这个函数.我们可以设计一个如:一只手机即是智能机,又是Andriod系统的. 比如:有个产品表里有一个type字段,他存储的是产品(手机)类型,有 1.智能机,2.Andri ...
- php download断点
FileDownload.class.php <?php /** php下载类,支持断点续传 * Date: 2013-06-30 * Author: fdipzone * Ve ...
- DW(三):polybase基本理论
PolyBase is a technology that accesses and combines(整合) both non-relational and relational data, all ...