1、orientation的默认值为horizontal,即从左向右排列。由于一般从上向下排列,所以必须指定orientation属性。

2、layout_gravity与gravity的区别:

(1)gravity指定自身所包含的子元素的对齐方式,如LinearLayout中的gravity指定了它的子元素(即5个TextView)水平居中排名,第二个TextView指定了其子元素(内容)向左对齐。

(2)layout_gravity用于指定自身在父元素中的对齐方式,并可覆盖其父元素的gravity属性。如第一个TextView指定了其自身在父元素(LinearLayou)中向右对齐,并覆盖了LinearLayout中的layout_gravity属性。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
android:gravity="center_horizontal"
tools:context=".MainActivity" > <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world"
android:layout_gravity="right"/> <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="@string/hello_world" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" /> </LinearLayout>

LinearLayout的一些注意事项的更多相关文章

  1. LinearLayout的一些注意事项 分类: H1_ANDROID 2013-10-26 23:01 856人阅读 评论(0) 收藏

    1.orientation的默认值为horizontal,即从左向右排列.由于一般从上向下排列,所以必须指定orientation属性. 2.layout_gravity与gravity的区别: (1 ...

  2. Android 使用DatePicker以及TimePicker显示当前日期和时间

    课程内容1.介绍DatePicker和TimePicker两种实现动态输入日期和事件的功能2.介绍DatePickerDialog和TimePickerDialog来年耕种实现动态输入日期和事件的对话 ...

  3. 关于Merge的整理--Merge的使用方法和注意事项的Demo

    上一篇文章中讲到了Merge的用法和注意事项,所以本人就想,做了一个Demo进行验证下. 一.Merge的使用 (1)activity中的onCreate方法中的setContentView(R.la ...

  4. Snackbar使用及其注意事项(转)

    http://blog.csdn.net/jywangkeep_/article/details/46405301 Snackbar使用及其注意事项 引言 Snackbar是Android Suppo ...

  5. ListView嵌套GridView使用详解及注意事项

    ListView嵌套GridView即ListView的每个Item中都包含一个GridView:需要注意的是由于ListView和GridView都是可滑动的控件. 所以需要自定义GridView, ...

  6. Androi Studio 之 LinearLayout

    LinearLayout •常用属性 •注意事项 当  android:orientation="vertical"  时, 只有水平方向的设置才起作用,垂直方向的设置不起作用 a ...

  7. jQuery UI resizable使用注意事项、实时等比例拉伸及你不知道的技巧

    这篇文章总结的是我在使用resizable插件的过程中,遇到的问题及变通应用的奇思妙想. 一.resizable使用注意事项 以下是我在jsfiddle上写的测试demo:http://jsfiddl ...

  8. Windows Server 2012 NIC Teaming介绍及注意事项

    Windows Server 2012 NIC Teaming介绍及注意事项 转载自:http://www.it165.net/os/html/201303/4799.html Windows Ser ...

  9. TODO:Golang指针使用注意事项

    TODO:Golang指针使用注意事项 先来看简单的例子1: 输出: 1 1 例子2: 输出: 1 3 例子1是使用值传递,Add方法不会做任何改变:例子2是使用指针传递,会改变地址,从而改变地址. ...

随机推荐

  1. Gruntjs构工具学习视频

    在这里推荐一个Gruntjs的学习视频,非常不错! http://www.imooc.com/learn/30

  2. replace 全局替换 和 数组去空

    <script> /*var str = 'a,b,dhhhh,d'; str = str.replace(/h/g,'j'); alert(str);*/ </script> ...

  3. block(四)揭开神秘面纱(下)

    看此篇时,请大家同时打开两个网址(或者下载它们到本地然后打开): http://llvm.org/svn/llvm-project/compiler-rt/trunk/lib/BlocksRuntim ...

  4. 可以让javascript加快的脚本(收藏了)

    <?php        ob_start('ob_gzhandler');        header("Cache-Control: public");        h ...

  5. BZOJ 3550 Vacation

    http://www.lydsy.com/JudgeOnline/problem.php?id=3550 题意:有3N个数,你需要选出一些数,首先保证任意长度为N的区间中选出的数的个数<=K个, ...

  6. HEX转BIN源码分析(51系列)

    以前写的一个Atmel的S5X的下载程序,其中有支持HEX格式的文件,所以将这个程序贴出来,程序的意思是将输入的HEX文件转换为BIN格式的文件,并存储到文件中,注意不支持64K的扩展模式. int ...

  7. 转:PO BO VO DTO POJO DAO概念及其作用

    J2EE开发中大量的专业缩略语很是让人迷惑,尤其是跟一些高手讨论问题的时候,三分钟就被人家满口的专业术语喷晕了,PO VO BO DTO POJO DAO,一大堆的就来了(听过老罗对这种现象的批判的朋 ...

  8. eclipse打开文件位置Open Explorer 插件

    ,OpenExplorer插件可以满足这个功能,可以到https://github.com/samsonw/OpenExplorer/downloads下载最新版本,将jar包放到eclipse的pl ...

  9. 转:更新Android SDK之后Eclipse提示ADT版本过低的一个简易解决办法

    拜GFW所赐,对于初学者的我来说,总会出现一些莫名其妙的问题 首先说明一下发表这一篇博文的“历史原因”吧,因为在更新SDK之后,进入Eclipse设置Android SDK目录的时候,会突然说我的版本 ...

  10. RFC3261--sip

    本文转载自 http://www.ietf.org/rfc/rfc3261.txt 中文翻译可参考 http://wenku.baidu.com/view/3e59517b1711cc7931b716 ...