android:linearlayout 学习
来源:互联网 发布:编写汇编语言的软件 编辑:程序博客网 时间:2024/05/18 20:33
android:gravity
该属性用于控制布局中控件的对齐方式。如果是没有子控件的控件设置此属性,表示其内容的对齐方式,比如说TextView里面文字的对齐方式;若是有子控件的控件设置此属性,则表示其子控件的对齐方式
android:weight
通过设置控件的layout_weight属性以控制各个控件在布局中的相对大小。layout_weight属性是一个非负整数值。线性布局会根据该控件layout_weight值与其所处布局中所有控件layout_weight值之和的比值为该控件分配占用的区域。例如,在水平布局的LinearLayout中有两个Button,这两个Button的layout_weight属性值都为1,那么这两个按钮都会被拉伸到整个屏幕宽度的一半。如果layout_weight指为0,控件会按原大小显示,不会被拉伸;对于其余layout_weight属性值大于0的控件,系统将会减去layout_weight属性值为0的控件的宽度或者高度,再用剩余的宽度或高度按相应的比例来分配每一个控件显示的宽度或高度
一个简单的应用布局文件:
<?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="红色" android:gravity="center_horizontal|center_vertical" android:background="#aa0000" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1"/> <TextView android:text="绿色" android:gravity="center_horizontal" android:background="#00aa00" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1"/> <TextView android:text="蓝色" android:gravity="center|bottom" android:background="#0000aa" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1"/> <TextView android:text="黄色" android:gravity="bottom" 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="第一行" android:textSize="15sp" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"/> <TextView android:text="第二行" android:textSize="15sp" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"/> <TextView android:text="第三行" android:textSize="15sp" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"/> <TextView android:text="第四列" android:textSize="15sp" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"/> </LinearLayout></LinearLayout>
- android:linearlayout 学习
- Android之LinearLayout学习
- android学习之LinearLayout
- 学习杂记:android布局 LinearLayout
- Android学习<LinearLayout, FrameLayout, RelativeLayout>
- Android--布局方式(LinearLayout)学习
- Android 学习笔记(3) --linearlayout
- Android学习-ScrollView LinearLayout View
- Android学习 - LinearLayout布局和RelativeLayout布局
- Android学习笔记06:线性布局LinearLayout
- android学习笔记01(LinearLayout)
- Android学习 7 -> 线型布局LinearLayout
- Android学习第一天之LinearLayout浅析
- Android学习笔记(11):线性布局LinearLayout
- Android学习笔记:线性布局LinearLayout
- Android学习笔记十三之LinearLayout布局
- [Android开发从零开始].10.LinearLayout学习
- Android学习笔记十三之LinearLayout布局
- HALCON算子函數——Chapter 2 : Control
- Windows下Android平台搭建_2
- HALCON算子函數——Chapter 1 : Classification
- vim定制细节
- 创业想法--情侣礼物商店
- android:linearlayout 学习
- 第7章 虚拟机类加载机制--《深入理解 Java 虚拟机》笔记
- JavaApplet遇到的一个问题及解决方法
- The Next Generation of Apache Hadoop MapReduce
- 网站页面路径小写变为大写
- Windows下Android平台搭建_3
- CSS3 RGBA
- 字符不能用逻辑或么?求解释 乱码笑脸是怎么回事?
- 10个迷惑新手的Cocoa,Objective-c开发难点和问题