Linear Layout

  • 新建项目HelloLinearLayout。
  • 打开 res/layout/main.xml文件,修改成下面的代码。

    <?xml version="1.0" encoding="utf-8"?>

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:orientation="vertical" android:layout_width="fill_parent"

    android:layout_height="fill_parent">

    <LinearLayout android:orientation="horizontal"

    android:layout_width="fill_parent" android:layout_height="fill_parent"

    android:layout_weight="1">

    <TextView android:text="red" android:gravity="center_horizontal"

    android:background="#aa0000" android:layout_width="wrap_content"

    android:layout_height="fill_parent" android:layout_weight="1" />

    <TextView android:text="green" android:gravity="center_horizontal"

    android:background="#00aa00" android:layout_width="wrap_content"

    android:layout_height="fill_parent" android:layout_weight="1" />

    <TextView android:text="blue" android:gravity="center_horizontal"

    android:background="#0000aa" android:layout_width="wrap_content"

    android:layout_height="fill_parent" android:layout_weight="1" />

    <TextView android:text="yellow" android:gravity="center_horizontal"

    android:background="#aaaa00" android:layout_width="wrap_content"

    android:layout_height="fill_parent" android:layout_weight="1" />

    </LinearLayout>

    <LinearLayout android:orientation="vertical"

    android:layout_width="fill_parent" android:layout_height="fill_parent"

    android:layout_weight="1">

    <TextView android:text="row one" android:textSize="15pt"

    android:layout_width="fill_parent" android:layout_height="wrap_content"

    android:layout_weight="1" />

    <TextView android:text="row 2" android:textSize="15pt"

    android:layout_width="fill_parent" android:layout_height="wrap_content"

    android:layout_weight="1" />

    <TextView android:text="row 3" android:textSize="15pt"

    android:layout_width="fill_parent" android:layout_height="wrap_content"

    android:layout_weight="1" />

    <TextView android:text="row 4" android:textSize="15pt"

    android:layout_width="fill_parent" android:layout_height="wrap_content"

    android:layout_weight="1" />

    </LinearLayout>

    </LinearLayout>

    上边的xml代码定义了一个垂直的LinearLayout,它包含了一个水平的LinearLayout和一个垂直的LinearLayout。然后每一个LinearLayout又包含了若干个TextView元素。

    允许程序结果如下:

    试着去改变layout_width的值,看看结果有什么不同。

转载于:https://www.cnblogs.com/xingquan/archive/2011/03/25/1995578.html

5.1 Android Basic QuickStart Layouts Linear Layout相关推荐

  1. android线性布局控制间隙,Android线性布局(Linear Layout)

    Android 中常用布局 [1] 线性布局 [2] 相对布局 [3] 帧布局  -- FrameLayout [4] 表格布局 -- !!!一个 tabrow 就代表一行 [5] 绝对布局   -- ...

  2. Android线性布局(Linear Layout)

    Android线性布局(Linear Layout) LinearLayout是一个view组(view group),其包含的所有子view都以一个方向排列,垂直或是水平方向.我们能够用androi ...

  3. android layout组件,Android UI学习 - Linear Layout, RelativeLayout

    1.一些常用的公共属性介绍 1) layout_width -宽 fill_parent: 宽度和父元素相同,wrap_content: 宽度随本身的内容所调整,或者指定 px值来设置宽 2) lay ...

  4. Android UI学习 - Linear Layout, RelativeLayout

    1. 一些常用的公共属性介绍 1) layout_width - 宽 fill_parent: 宽度和父元素相同,wrap_content: 宽度随本身的内容所调整,或者指定 px 值来设置宽 2) ...

  5. android线性布局快捷键,【整理】Android图形界面知识学习与总结之:Linear Layout线性布局...

    [背景] 之前已经学习了: 现在接着去学习: 整理如下: Linear Layout 1.LinearLayout是一个视图组合 2.LinearLayout中的子视图只能已单个方向排列,要么是水平, ...

  6. Android用户界面布局(layouts)

    Android用户界面布局(layouts) 备注:view理解为视图 一个布局定义了用户界面的可视结构,比如activity的UI或是APP widget的UI,我们可以用下面两种方式来声明布局: ...

  7. Android自定义水波纹动画Layout

    Android自定义水波纹动画Layout 源码是双11的时候就写好了,但是我觉得当天发不太好,所以推迟了几天,没想到过了双11女友就变成了前女友,桑心.唉不说了,来看看代码吧. 展示效果 Hi前辈 ...

  8. style=@android:style/buttonbar,Setting style=?android:attr/buttonBarStyle to parent layout and s...

    I followed Android recommendation and set style="?android:attr/buttonBarStyle" to parent l ...

  9. android 半边圆角背景,Android UI(一)Layout 背景局部Shape圆角设计

    Jeff Lee blog:   http://www.cnblogs.com/Alandre/  (泥沙砖瓦浆木匠),retain the url when reproduced ! Thanks ...

最新文章

  1. 汉诺塔问题java编程,Java经典编程300例之实例047 汉诺塔问题求解(递归)
  2. 起步,停车——走好你的IT运维管理之路
  3. SQLite多线程使用总结
  4. 多线程:CopyOnWriteArrayList
  5. mysql中类型转换
  6. sql语句distinct_带DISTINCT子句SQL SELECT语句
  7. 计算机信应用技术,计算机信息应用技术.ppt
  8. 黑域 绿色守护 安卓最好的省电工具?
  9. 服务器lsass系统错误,电脑开机提示lsass.exe系统错误无法进入系统的解决方法
  10. 中华石杉Java面试突击第一季笔记二(分布式搜索引擎)
  11. python安装jupter在线ide
  12. psd导出jpg太大_保存技巧,完美解决PS导出文件过大的问题
  13. 中国标准时间和时间戳互转
  14. LED办公楼宇照明节能方案及城市夜景照明节能方案
  15. iOS开发者,金九银十,这样写简历才能让大厂面试官看重你!
  16. 通过Nginx访问静态页面
  17. Windows不显示图片缩略图,显示图标的解决方法
  18. VMware12安装图解
  19. 全双工通信的 WebSocket
  20. stm32f103停止模式低功耗设置(最低5.7ua)

热门文章

  1. HashMap(Java)
  2. S5PV210开发 -- 通信
  3. phpcms 指定id范围 调用_phpcms v9使用GET调用指定id文章内容、页面数据方法
  4. APK加密方法:某社交类Android APP加密分享
  5. wp cron.php,wordpress定时任务(wp-cron.php)造成主机CPU比较高的解决办法
  6. BZOJ 2038: [2009国家集训队]小Z的袜子(莫队算法例题)
  7. JZOJ 5177. 【NOIP2017提高组模拟6.28】TRAVEL
  8. /usr/include/boost/type_traits/detail/has_binary_operator.hp:50: Parse error at BOOST_JOIN错误
  9. Qt 清空QPixMap
  10. 什么是方向图乘积定理_初中数学竞赛试题——正多边形与托勒密定理