##常见的布局
* LinearLayout 线性布局
线性布局往左右拉是拉不动的,
> 线性布局的朝向 vertical|horizontal
> 线性布局的权重 weight 和 0dip一起使用

<?xml version="1.0" encoding="utf-8"?>
<!-- 线性布局控件自上而下整齐的排列 -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > 垂直排列,里面的内容垂直排列 <Button
android:layout_width="match_parent"
android:layout_height="0dip" 高度为0,则高度根据权重来占比例,
android:layout_weight="1" 权重为1,则高度为权重和的1份即1/3,权重只能跟为0的宽度或高度,
android:text="按钮1" /> <Button
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:text="按钮2" /> <Button
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:text="按钮3" /> </LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<!-- 线性布局控件自左向右整齐的排列 -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" > 水平排列,不用权重则多的将会挤出去, <Button
android:layout_width="0dip" 宽度为0,
android:layout_height="wrap_content" 高度填充父窗体,和父组件宽度一样宽,
android:layout_weight="2" 权重为2,则宽度为权重和的2份即2/4,权重只能跟为0的宽度或高度,
android:text="按钮1" /> <Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1" 权重为1,则宽度为权重和的1份
android:text="按钮2" /> <Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1" 权重为1,则宽度为权重和的1份
android:text="按钮3" /> </LinearLayout>

以上的代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > 最外层是线性布局,垂直排列 <LinearLayout
android:orientation="horizontal" 里面是水平排列
android:layout_width="match_parent" 宽度为父窗体宽度
android:layout_weight="1" 权重为1
android:layout_height="0dip" > 写0可以用权重了
<TextView
android:layout_width="0dip" 宽度为0
android:layout_height="fill_parent" 高度为父窗体
android:layout_weight="1" 宽度权重为1
android:background="#ff0000"
/>
<TextView
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#00ff00"
/>
<TextView
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#0000ff"
/> </LinearLayout> <LinearLayout
android:orientation="vertical" 里面垂直排列
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="0dip" >
<TextView
android:layout_width="fill_parent" 宽度为父窗体
android:layout_height="0dip" 高度为0
android:layout_weight="1" 高度权重为1
android:background="#ff0000"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:background="#00ff00"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:background="#0000ff"
/> </LinearLayout> </LinearLayout>

android 59 LinearLayout 线性布局的更多相关文章

  1. Android之LinearLayout线性布局

    1.相关术语解释 orientation 子控件的排列方式,horizontal(水平)和vertical(垂直默认)两种方式! gravity 子控件的对齐方式,多个组合 layout_gravit ...

  2. Android 自学之线性布局 LinearLayout

    线性布局(LinearLayout),线性布局有点想AWT编程里面的FolwLayout,他们都会将容器里面的组件挨个的排列起来. 他们最大的区别在于:Android的线性布局不会换行:AWT里面的F ...

  3. Android布局管理详解(1)—— LinearLayout 线性布局

    Android的布局方式共有6种,分别是LinearLayout(线性布局).TableLayout(表格布局).FrameLayout(帧布局).RelativeLayout(相对布局).GridL ...

  4. Android精通:View与ViewGroup,LinearLayout线性布局,RelativeLayout相对布局,ListView列表组件

    UI的描述 对于Android应用程序中,所有用户界面元素都是由View和ViewGroup对象构建的.View是绘制在屏幕上能与用户进行交互的一个对象.而对于ViewGroup来说,则是一个用于存放 ...

  5. Android零基础入门第25节:最简单最常用的LinearLayout线性布局

    原文:Android零基础入门第25节:最简单最常用的LinearLayout线性布局 良好的布局设计对于UI界面至关重要,在前面也简单介绍过,目前Android中的布局主要有6种,创建的布局文件默认 ...

  6. 2.2.1 LinearLayout(线性布局)

    本节引言 本节开始讲Android中的布局,Android中有六大布局,分别是: LinearLayout(线性布局), RelativeLayout(相对布局), TableLayout(表格布局) ...

  7. Android LinearLayout线性布局

    LinearLayout是线性布局控件:要么横向排布,要么竖向排布 决定性属性:必须有的! android:orientation:vertical (垂直方向) .horizontal(水平方向) ...

  8. .Net程序猿玩转Android开发---(6)线性布局LinearLayout

                                LinearLayout控件是Android中重要的布局控件,是一个线性控件,所谓线性控件的意思是指该控件里面的内容仅仅能水平或垂直排列.也就 ...

  9. Android开发之线性布局详解(布局权重)

    布局权重 线性布局支持给个别的子视图设定权重,通过android:layout_weight属性.就一个视图在屏幕上占多大的空间而言,这个属性给其设 定了一个重要的值.一个大的权重值,允许它扩大到填充 ...

随机推荐

  1. 第 11 章 桥梁模式【Bridge Pattern】

    以下内容出自:<<24种设计模式介绍与6大设计原则>> 今天我要说说我自己,梦想中的我自己,我身价过亿,有两个大公司,一个是房地产公司,一个是服装制造业,这两个公司都很赚钱,天 ...

  2. nojs iis asp.net mvc

    http://blogs.msdn.com/b/scott_hanselman/archive/2011/11/29/window-iis-node-js.aspx http://www.hansel ...

  3. 如何把关联性的告警智能添加到 Nagios 上?(2)

    上节回顾 对于许多 IT 和运维团队来说,Nagios 既是一个福音也是一个诅咒.一方面,Naigos 在 IT 应用的工作领域中,给予了你可以实时查看告警数据的可能性:但是另一方面,Nagios 也 ...

  4. Android学习及如何利用android来赚钱

    一.如何学习Android      android开发(这里不提platform和底层驱动)你需要对Java有个良好的基础,一般我们用Eclipse作为开发工具.对于过多的具体知识详细介绍我这里不展 ...

  5. Android JNI使用方法

    经过几天的努力终于搞定了android JNI部分,下面将我的这个小程序和大家分享一下.android JNI是连接android Java部分和C/C++部分的纽带,完整使用JNI需要Java代码和 ...

  6. hadoop多机安装YARN

    hadoop伪分布安装称为测试环境安装,多机分布称为生成环境安装.以下安装没有进行HA(热备)和Federation(联邦).除非是性能需要,否则没必要安装Federation,HA可以一试,涉及到Z ...

  7. minicom-2.4安装配置

    minicom-2.4安装说明 1.#tar –zxvf minicom-2.4.tar.gz 解压开有连个文件,minicom-2[1].4.tar.gz  和minirc.dfl rpm包方式# ...

  8. bzoj1264

    表面上看这是一道LCS问题 LCS问题O(n2)的复杂度已经很优秀了 而这道题需要O(nlogn)以下的复杂度才能AC 所以我们要找经典问题的特殊性 特殊就在这两个串中,每个数字都是恰好出现5次 不难 ...

  9. Java中文乱码解决

    Jvm内部编码采用的是Unicode编码. 常见的字符编码集:ASCII编码,GBK编码,Unicode编码 UTF-8只是unicode的实现方式之一: UTF-8最大的一个特点,就是它是一种变长的 ...

  10. VM Depot 喜迎中国本土开源镜像!

     发布于 2014-04-07 作者 陈 忠岳 VM Depot 登陆中国之际,我非常高兴地告诉大家,一批各位耳熟能详的中国本地开源镜像已同时上线!得益于开源社区的大力支持,Ubuntu 麒麟13 ...