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属性.就一个视图在屏幕上占多大的空间而言,这个属性给其设 定了一个重要的值.一个大的权重值,允许它扩大到填充 ...
随机推荐
- 如何跳到系统设置界面-b
NSURL *url = [NSURL URLWithString:@"prefs:root=WIFI"]; if ([[UIApplication sharedApplicati ...
- XMLHttpRequest 使用概括
***********************************************XMLHttpRequest对象初始化:********************************* ...
- 如何监控 Tomcat?Zabbix 与 Cloud Insight 对比
JVM 监控工具有很多,像命令 jstat,jmap,jstack,jinfo 可以根据不同需求查看不同的系统信息,还有图像化界面 jconsole,都是很方便的工具.这些可以参考 JAVA自带监控工 ...
- Web API路由与动作(三)
本章包括三个小节 如果你输入了mvc的路由规则 这个可以粗略过一遍即可 内容说明有点繁琐 原文地址:http://www.asp.net/web-api/overview/web-api-rout ...
- Google 发布 Android 性能优化典范
2015年伊始,Google发布了关于Android性能优化典范的专题, 一共16个短视频,每个3-5分钟,帮助开发者创建更快更优秀的Android App.课程专题不仅仅介绍了Android系统中有 ...
- [cocos2d]场景切换以及切换进度显示
本文主要分两个部分叙述,第一是场景切换,第二是场景切换的进度显示. 一.场景切换 参考learn-iphone-and-ipad-cocos2d-game-development 第五章内容 coco ...
- 使用vs自带的wcf配置工具
服务和行为是并列的 对应到配置文件中 wcf的配置在system.serviceModel中 可以有多个服务 一个服务会有一个主机以及多个终结点 主机包含多个基址 baseAddress 终结点,由 ...
- DevExpress右键菜单使用 zt
添加BarManager和popupMenu组建: 设置popupMenu组件的Manager属性: 右键点击popupMenu主键,点击Customize选项添加菜单: 然后便可添加到鼠标事件中 ...
- HDU-1045 Fire Net
http://acm.hdu.edu.cn/showproblem.php?pid=1045 Fire Net Time Limit: 2000/1000 MS (Java/Others) Me ...
- SCI写作经典替换词,瞬间高大上!(转)
转自微信:http://mp.weixin.qq.com/s?__biz=MzA4NDk3ODEwNQ==&mid=202006470&idx=2&sn=e8900b94448 ...