LinearLayout学习笔记
线性布局分两种,分别是水平线性布局和垂直线性布局,对应设置为android:orientation="horizontal"/"vertical".
LinearLayout其他XML属性还包括(为列举完全,完整的请参考官方帮助文档):
android:baselineAligned:是否允许用户调整它内容的基线. (属性值可以设置为true/false,具体请参考http://www.cnblogs.com/JohnTsai/p/4074643.html)
android:gravity:指定如何在该对象中放置此对象的内容(x/y坐标值). android:gravity="top"(buttom、left、right、center_vertical、fill_vertical、center_horizontal、fill_horizontal、center、fill、clip_vertical、clip_horizontal)控制布局中控件的对齐方式。如果是没有子控件的控件设置此属性,表示其内容的对齐方式,比如说TextView里面文字的对齐方式;若是有子控件的控件设置此属性,则表示其子控件的对齐方式,gravity如果需要设置多个属性值,需要使用“|”进行组合. (android:gravity 与 android:layout_gravity的区别 android:gravity是指定本元素的子元素相对它的对齐方式,android:layout_gravity是指定本元素相对于它的父元素的对齐方式.)
LinearLayout实现效果(嵌套线性布局,最外面为垂直线性布局,里面上半部分水平,下半部分垂直)

布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"> <LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"> <TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="green"
android:background="#00aa00"
android:layout_weight="1" /> <TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="red"
android:layout_weight="1"
android:background="#aa0000"/> <TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="blue"
android:layout_weight="1"
android:background="#0000aa"/>
</LinearLayout> <LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"> <TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="row_one"
android:textSize="15pt"
android:layout_weight="1"/> <TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="row_two"
android:textSize="15pt"
android:layout_weight="1"/> <TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="row_three"
android:textSize="15pt"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
LinearLayout学习笔记的更多相关文章
- 【转】Pro Android学习笔记(二五):用户界面和控制(13):LinearLayout和TableLayout
目录(?)[-] 布局Layout 线性布局LinearLayout 表格布局TableLayout 布局Layout Layout是容器,用于对所包含的view进行布局.layout是view的子类 ...
- Android学习笔记(二十二)——短信接收与发送
//此系列博文是<第一行Android代码>的学习笔记,如有错漏,欢迎指正! 当手机接收到一条短信的时候, 系统会发出一条值为 android.provider.Telephony.SMS ...
- Android学习笔记(二十一)——实战:程序数据共享
//此系列博文是<第一行Android代码>的学习笔记,如有错漏,欢迎指正! 我们继续在Database项目的基础上继续开发,通过内容提供器来给它加入外部访问接口.首先将 MyDataba ...
- Android学习笔记(十九)——内容提供器
//此系列博文是<第一行Android代码>的学习笔记,如有错漏,欢迎指正! 内容提供器(Content Provider)主要用于在不同的应用程序之间实现数据共享的功能,它提供了一套完整 ...
- Android学习笔记(十二)——实战:制作一个聊天界面
//此系列博文是<第一行Android代码>的学习笔记,如有错漏,欢迎指正! 运用简单的布局知识,我们可以来尝试制作一个聊天界面. 一.制作 Nine-Patch 图片 : Nine-Pa ...
- Android学习笔记(十)——ListView的使用(上)
//此系列博文是<第一行Android代码>的学习笔记,如有错漏,欢迎指正! ListView绝对可以称得上是 Android中最常用的控件之一,ListView允许用户通过手指上下滑动的 ...
- Android学习笔记(九)——布局和控件的自定义
//此系列博文是<第一行Android代码>的学习笔记,如有错漏,欢迎指正! View是 Android中一种最基本的 UI组件,它可以在屏幕上绘制一块矩形区域,并能响应这块区域的各种事件 ...
- Android学习笔记(八)——四种基本布局
//此系列博文是<第一行Android代码>的学习笔记,如有错漏,欢迎指正! 布局是一种可用于放置很多控件的容器,它可以按照一定的规律调整内部控件的位置,或是嵌套子布局,从而编写出精美的界 ...
- Android学习笔记(二)——探究一个活动
//此系列博文是<第一行Android代码>的学习笔记,如有错漏,欢迎指正! 活动(Activity)是最容易吸引到用户的地方了,它是一种可以包含用户界面的组件,主要用于和用户进行交互.一 ...
随机推荐
- 感谢各位亲们的大力支持,免费的HTML5学习课程《HTML5网页开发实例具体解释》连载已经结束了!
感谢各位亲们的大力支持,免费的HTML5学习课程<HTML5网页开发实例具体解释>连载已经结束了. 有兴趣的读者能够看我的博客,也能够看以下的链接逐个学习: 当里个当.免费的HTML5连 ...
- this总结
this总结,mark一下: Object中的this: Object方法中的this,指向的就是该对象,即谁调用this就指向谁,与C#等服务器语言的思想比较一致. let demo = { nam ...
- 第四章 事务(MYBatis)
一个使用 MyBatis-Spring 的主要原因是它允许 MyBatis 参与到 Spring 的事务管理中.而不是给 MyBatis 创建一个新的特定的事务管理器,MyBatis-Spring 利 ...
- Android SDK的安装教程
Android4.1虽说已经发布了好些天,但由于的我手机比较坑,系统依旧保持在2.3.4.0的都是可望不可即的了,就别说4.1.由于资金的问题,没法换手机,只能另想方法,通过在笔记本上装andro ...
- 巧妙的利用Mongodb做地理空间查询
- mysql数据库中,查看某个数据库下的表的存储类型都有哪些
需求描述: 在备份数据库的时候,使用mysqldump进行数据库的备份,如果库中仅仅有innodb存储引擎, 那么使用--single-transaction就可以,如果还有其他的存储引擎类型就要使用 ...
- HTML5 直播技术
https://segmentfault.com/a/1190000010440054
- 一、NHibernate配置所支持的属性
属性名 用途 dialect 设置NHibernate的Dialect类名 - 允许NHibernate针对特定的关系数据库生成优化的SQL 可用值: full.classname.of.Dialec ...
- android:json解析的两个工具:Gson和Jackson的使用小样例
1.简单介绍 json是android与server通信过程中经常使用的数据格式,比如.例如以下是一个json格式的字符串: {"address":"Nanjing&qu ...
- C#------各种数据库连接字符串编写
转载: https://www.connectionstrings.com/