android 59 LinearLayout 线性布局
##常见的布局
* 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 线性布局的更多相关文章
- Android之LinearLayout线性布局
1.相关术语解释 orientation 子控件的排列方式,horizontal(水平)和vertical(垂直默认)两种方式! gravity 子控件的对齐方式,多个组合 layout_gravit ...
- Android 自学之线性布局 LinearLayout
线性布局(LinearLayout),线性布局有点想AWT编程里面的FolwLayout,他们都会将容器里面的组件挨个的排列起来. 他们最大的区别在于:Android的线性布局不会换行:AWT里面的F ...
- Android布局管理详解(1)—— LinearLayout 线性布局
Android的布局方式共有6种,分别是LinearLayout(线性布局).TableLayout(表格布局).FrameLayout(帧布局).RelativeLayout(相对布局).GridL ...
- Android精通:View与ViewGroup,LinearLayout线性布局,RelativeLayout相对布局,ListView列表组件
UI的描述 对于Android应用程序中,所有用户界面元素都是由View和ViewGroup对象构建的.View是绘制在屏幕上能与用户进行交互的一个对象.而对于ViewGroup来说,则是一个用于存放 ...
- Android零基础入门第25节:最简单最常用的LinearLayout线性布局
原文:Android零基础入门第25节:最简单最常用的LinearLayout线性布局 良好的布局设计对于UI界面至关重要,在前面也简单介绍过,目前Android中的布局主要有6种,创建的布局文件默认 ...
- 2.2.1 LinearLayout(线性布局)
本节引言 本节开始讲Android中的布局,Android中有六大布局,分别是: LinearLayout(线性布局), RelativeLayout(相对布局), TableLayout(表格布局) ...
- Android LinearLayout线性布局
LinearLayout是线性布局控件:要么横向排布,要么竖向排布 决定性属性:必须有的! android:orientation:vertical (垂直方向) .horizontal(水平方向) ...
- .Net程序猿玩转Android开发---(6)线性布局LinearLayout
LinearLayout控件是Android中重要的布局控件,是一个线性控件,所谓线性控件的意思是指该控件里面的内容仅仅能水平或垂直排列.也就 ...
- Android开发之线性布局详解(布局权重)
布局权重 线性布局支持给个别的子视图设定权重,通过android:layout_weight属性.就一个视图在屏幕上占多大的空间而言,这个属性给其设 定了一个重要的值.一个大的权重值,允许它扩大到填充 ...
随机推荐
- C语言写解一元二次方程程序心得
前言:在网上看到不少解一元二次方程的小程序,在使用时总得出一大堆小数,感觉很不爽,遂自己重新写了一遍. 首先,先回忆一下一元二次方程的求根公式: 分别读取二次项.一次项和常数项系数并且求出delta ...
- Android 自定义RadioButton实现
由于使用小米系统MIUI运行是RadioButton样式跟google Android API自定义的不一样,则我们可以定义任何想要的东东.没有做不到,只有想不到 Android 自定义RadioBu ...
- C连接MySQL数据库开发之Linux环境完整示例演示(增、删、改、查)
一.开发环境 ReadHat6.3 32位.mysql5.6.15.gcc4.4.6 二.编译 gcc -I/usr/include/mysql -L/usr/lib -lmysqlclient ma ...
- css3加载中
.loader { margin: 6em auto; font-size: 10px; position: relative; text-indent: -9999em; border-top: 1 ...
- Colored Sticks
poj2513:http://poj.org/problem?id=2513 题意:就是求一个欧拉回路. 题解:本题是判断欧拉通路是否存在,但是如果是用map的话就会超时,这里采用了trie树,有发现 ...
- http://www.cnblogs.com/xdp-gacl/p/4040019.html
http://www.cnblogs.com/xdp-gacl/p/4040019.html
- insert into select 堵塞update
mysql[192.168.5.15] blocking_thread[2286333] blocking_query[insert into temp_zhuyou_mktact_1(hotel_g ...
- Power Strings
Power Strings TimeLimit: 1 Second MemoryLimit: 32 Megabyte Totalsubmit: 1791 Accepted: 528 Descr ...
- vijosP1006 晴天小猪历险记之Hill
vijosP1006 晴天小猪历险记之Hill 链接:https://vijos.org/p/1006 [思路] 图上DP. 这个题的递推顺序是关键.先从上一行得到最小值,然后从本行比较最小值,注意本 ...
- 我的第一个JApplet-绘制笑脸
初学Java,有很多东西都不太理解,但是我想以前初学C语言的时候也是不太懂,先参考着书上的程序写,然后用多了就自然而然的懂了! 下面来简单的介绍一下我自学的第一个Java小应用程序-绘制笑脸,下面是源 ...