##常见的布局
* 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. 关于Java(Hello World程序)

    详解 Hello World 应用程序 源码 class HelloWorldApp { public static void main(String[] args) { System.out.pri ...

  2. ACM俱乐部算法基础练习赛(1)

    A: 水题 代码: #include<cstdio> #include<algorithm> using namespace std; ]; int n,m,c; int ma ...

  3. Android-x86虚拟机安装配置全攻略

    转自Android-x86虚拟机安装配置全攻略 注:这里安装从简,具体请参考虚拟机Vmware安装运行安卓4.0详细教程 Android-x86虚拟机安装配置网上有很多,但是全部说明白的确不多,希望这 ...

  4. Hibernate 注解时 hibernate.hbm.xml的配置方法 以及与SSH整合里的配置方式

    ①纯Hibernate开发: 当你在Bean中写入注解后,需要告诉hibernate哪些类使用了注解. 方法是在hibernate.hbm.xml文件中配置 <!DOCTYPE hibernat ...

  5. javascript中通过replace函数搜索和替换指定字符串

    javascript中我们可以通过replace函数替换部分字符串为指定字符串,本文展示了replace的详细用法,并且通过范例演示了如何进行部分替换.完整替换和不区分大小写替换. javascrip ...

  6. CF_91B

    题目意思是这样的:给定n个整数,求第i个数右边的距离它最远的比它小的数的下标之差然后再减1. 这里既然是需要知道距离该数最远的下标,可以从右至左扫描一遍,然后按照单调递减的顺序入栈,即只把比栈顶元素小 ...

  7. 码云分布式之 Brzo 服务器

    摘要: 码云是国内最大的代码托管平台,为了支持更大的用户规模,开发团队也在对一些组件进行大规模的重构. 前言 码云是国内最大的代码托管平台.码云基于 Gitlab 5.5 开发,经过几年的开发已经和官 ...

  8. bower初接触

    之前从Steve Sanderson的博文Architecting large Single Page Applications with Knockout.js中学习了用Yeoman创建Knocko ...

  9. logstash date插件

    [elk@dr-mysql01 api-access]$ date Wed Nov 30 19:21:35 CST 2016 [elk@dr-mysql01 api-access]$ [elk@dr- ...

  10. Android应用开发性能优化完全分析

    1 背景 其实有点不想写这篇文章的,但是又想写,有些矛盾.不想写的原因是随便上网一搜一堆关于性能的建议,感觉大家你一总结.我一总结的都说到了很多优化注意事项,但是看过这些文章后大多数存在一个问题就是只 ...