Linear Layout(线性布局)
来源:互联网 发布:thinkphp旅游网站源码 编辑:程序博客网 时间:2024/04/20 03:06
Linear Layout
LinearLayout是一个排列子元素单一方向(横向或纵向)的view组。你可以通过android:orientation属性指定一个布局方向。
LinearLayout的所有子元素一个接一个的堆放在一起,因此一个纵向列表只有一个任意宽度的列,一个横向的布局只有一行(他的高度取决于他最高的子元素的高的和填充部分的和)。LinearLayout的边距由他的子元素和每个子元素在该容器内的位置决定(中心、靠右、左对齐)。
Layout Weight
LinearLayout 也可以通过 android:layout_weight属性为他的子元素指定重要性,为这个属性分配一个重要性的值来决定一个元素在屏幕中占多大的空间。大的weight属性值可以使组件扩充多余的空间充满父组件。子元素可以分配一个Weight属性值,剩余的空间根据每个元素的Weight值来按比例分配给每个元素。默认的Weight是0。
假如现在有三个TextView元素,其中两个的weight属性为“1”,另外一个没有指定weight属性,第三个元素是不能进行扩展的,他占有的空间需要根据他的内容而定。其他的两个元素将平分剩余的空间。如果指定第三个元素的weight为“2”,则他将占据总空间的一半,另外的两个元素平分剩余的空间。
Example
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingLeft="16dp" android:paddingRight="16dp" android:orientation="vertical" > <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:hint="@string/to" /> <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:hint="@string/subject" /> <EditText android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="1" android:gravity="top" android:hint="@string/message" /> <Button android:layout_width="100dp" android:layout_height="wrap_content" android:layout_gravity="right" android:text="@string/send" /></LinearLayout>
- Linear Layout(线性布局)
- Android布局---线性布局(Linear Layout)
- 线性布局 Linear Layout
- 布局(线性布局 Linear Layout )相对布局 (Relative Layout)
- Android线性布局(Linear Layout)
- Android线性布局(Linear Layout)
- Linear Layout(线形布局)
- Android UI Design 03 : 线性布局 Linear Layout
- 尝试式android自学教程-linear layout(线性布局)
- Android开发教程 --- 布局(线性布局 Linear Layout )(相对布局 Relative Layout)
- Linear Layout 布局技巧
- Layout布局之线性布局
- Android布局之一——Linear Layout
- 11 - 布局Layout:LinearLayout线性布局
- Linear Layout
- Linear Layout
- Linear Layout
- 线性回归(linear regression)
- 图片处理--压缩图片
- 三层架构——实践篇(小Demo,大道理)
- Android实现界面跳转
- JUnit学习笔记
- Andriod中textview垂直水平居中及LinearLayout内组件的垂直布局
- Linear Layout(线性布局)
- Test
- 女人需谨记的十六条健康戒律
- linuxi学习curses(1)
- 背完这444句,你的口语绝对不成问题了
- c++ string double 互转
- linuxi学习curses(2) 时间显示器
- html5 背后新增的api--给自己看的
- linux安装分区大小分配