线性布局分两种,分别是水平线性布局和垂直线性布局,对应设置为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学习笔记的更多相关文章

  1. 【转】Pro Android学习笔记(二五):用户界面和控制(13):LinearLayout和TableLayout

    目录(?)[-] 布局Layout 线性布局LinearLayout 表格布局TableLayout 布局Layout Layout是容器,用于对所包含的view进行布局.layout是view的子类 ...

  2. Android学习笔记(二十二)——短信接收与发送

    //此系列博文是<第一行Android代码>的学习笔记,如有错漏,欢迎指正! 当手机接收到一条短信的时候, 系统会发出一条值为 android.provider.Telephony.SMS ...

  3. Android学习笔记(二十一)——实战:程序数据共享

    //此系列博文是<第一行Android代码>的学习笔记,如有错漏,欢迎指正! 我们继续在Database项目的基础上继续开发,通过内容提供器来给它加入外部访问接口.首先将 MyDataba ...

  4. Android学习笔记(十九)——内容提供器

    //此系列博文是<第一行Android代码>的学习笔记,如有错漏,欢迎指正! 内容提供器(Content Provider)主要用于在不同的应用程序之间实现数据共享的功能,它提供了一套完整 ...

  5. Android学习笔记(十二)——实战:制作一个聊天界面

    //此系列博文是<第一行Android代码>的学习笔记,如有错漏,欢迎指正! 运用简单的布局知识,我们可以来尝试制作一个聊天界面. 一.制作 Nine-Patch 图片 : Nine-Pa ...

  6. Android学习笔记(十)——ListView的使用(上)

    //此系列博文是<第一行Android代码>的学习笔记,如有错漏,欢迎指正! ListView绝对可以称得上是 Android中最常用的控件之一,ListView允许用户通过手指上下滑动的 ...

  7. Android学习笔记(九)——布局和控件的自定义

    //此系列博文是<第一行Android代码>的学习笔记,如有错漏,欢迎指正! View是 Android中一种最基本的 UI组件,它可以在屏幕上绘制一块矩形区域,并能响应这块区域的各种事件 ...

  8. Android学习笔记(八)——四种基本布局

    //此系列博文是<第一行Android代码>的学习笔记,如有错漏,欢迎指正! 布局是一种可用于放置很多控件的容器,它可以按照一定的规律调整内部控件的位置,或是嵌套子布局,从而编写出精美的界 ...

  9. Android学习笔记(二)——探究一个活动

    //此系列博文是<第一行Android代码>的学习笔记,如有错漏,欢迎指正! 活动(Activity)是最容易吸引到用户的地方了,它是一种可以包含用户界面的组件,主要用于和用户进行交互.一 ...

随机推荐

  1. 关于Cocos2d-x中字体的使用

    1.如果使用的是系统自带的 static Label* createWithSystemFont ( const std::string & text,        const std::s ...

  2. C++ STL 教程

    C++ STL 教程在前面的章节中,我们已经学习了 C++ 模板的概念.C++ STL(标准模板库)是一套功能强大的 C++ 模板类,提供了通用的模板类和函数,这些模板类和函数可以实现多种流行和常用的 ...

  3. Python下opencv使用笔记(十)(图像频域滤波与傅里叶变换)

    前面以前介绍过空间域滤波,空间域滤波就是用各种模板直接与图像进行卷积运算,实现对图像的处理,这个方案直接对图像空间操作,操作简单.所以也是空间域滤波. 频域滤波说究竟终于可能是和空间域滤波实现相同的功 ...

  4. struct iphdr中的__LITTLE_ENDIAN_BITFIELD和__BIG_ENDIAN_BITFIELD

    __LITTLE_ENDIAN_BITFIELD表示小端序,__BIG_ENDIAN_BITFIELD表示大端序. /usr/include/linux/ip.h中有一段代码定义了ip首部的结构体,例 ...

  5. fastx tookit 操作fasta/fastq 文件 (1)

    准备测试文件 test.fq, 包含4条fastq 文件,碱基编码格式为phred64; @FC12044_91407_8_200_406_24 NTTAGCTCCCACCTTAAGATGTTTA + ...

  6. strusts annotation

    也叫Zero Configuration(零配置),它省去了写xml文件的麻烦,可以直接在类叫进行配置,不用在java文件和xml文件中来回切换. 1.Action级的注解 @ParentPackag ...

  7. 双十二“MathType”限时6折特惠

    MathType是由美国Design Science公司开发功能强大的公式编辑器,专门用来对数学公式的编辑,与常见的文字处理软件和演示程序配合使用,能够在各种文档中加入复杂的数学公式和符号.双十二期间 ...

  8. #import 无法打开源文件msado.tlh

    #import 无法打开源文件msado.tlh #import "c:\program files\common files\system\ado\msado15.dll" no ...

  9. 左连接去重(objec)

    需求场景: 1.前端使用的object-table(angularJs) 2.自定义模糊查询 可以模糊查询主表,主表没有数据的时候,可通过字表的(name或者hostname)字段来查询(主-子:一对 ...

  10. NopCommerce的定时任务分析和应用

    NOP的定时任务也是群里听群友听说,我很少在WEB端做定时任务,所以尝鲜下,看看效果怎么样. 主要涉及到下面几个类和配置文件配置: web.config <configSections> ...