[Android]线性布局
来源:互联网 发布:基金数据库 编辑:程序博客网 时间:2024/06/04 21:15
LinearLayout即:线性布局,是一个视图组。用于对齐所有的其包含的子视图。所有的子视图在一个方向,垂直或水平。可以通过android:orientation 属性来指定布局方向。
All children of a LinearLayout are stacked one after the other, so a vertical list will only have one child per row, no matter how wide they are, and a horizontal list will only be one row high (the height of the tallest child, plus padd ing). A LinearLayout respects margins between children and the gravity (right, center, or left alignment) of each child.
所有子视图被挨个堆放,所有如果是垂直方向,每一行将只有一个子视图;如果是水平方向,将只会有一行。线性布局指示了子视图之间的权重,比如靠右对齐,居中对齐,左对齐等。
线性布局还有一个很重要的属性:android:layout_weight。它表示子视图在整个线性布局中所占的权重,权重越大,所占有的屏幕比例越大。
下面通过一个简单的登录功能,展示线性布局的使用。
<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:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:paddingLeft="10dp" android:paddingRight="10dp" android:paddingTop="100dp" > <TextView android:layout_width="80dp" android:layout_height="50dp" android:text="@string/username" android:textSize="20sp" /> <EditText android:layout_width="match_parent" android:layout_height="50dp" android:hint="@string/placeholder" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:paddingLeft="10dp" android:paddingTop="30dp" > <TextView android:layout_width="80dp" android:layout_height="50dp" android:text="@string/password" android:textSize="20sp" /> <EditText android:layout_width="match_parent" android:layout_height="50dp" android:hint="@string/placeholder2" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:orientation="horizontal" android:paddingLeft="10dp" android:paddingRight="10dp" android:paddingTop="100dp" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/login" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:hint="@string/reset" /> </LinearLayout></LinearLayout>
0 0
- android布局之线性布局
- android布局之线性布局
- Android布局之线性布局
- Android布局之线性布局
- android 布局学习---线性布局
- android布局之线性布局
- Android布局之线性布局
- Android 布局LinearLayout(线性布局)
- Android 线性布局详解
- Android线性布局
- Android 线性布局:LinearLayout
- android 线性布局
- Android线性布局
- android线性布局
- android界面线性布局
- Android 线性布局详解
- Android线性布局自适应
- android的线性布局
- 10秒后显示图片
- ARM linux kernel启动流程
- struct msghdr
- MySQl自动编号与主键
- Dom-docment-通过节点层次关系获取
- [Android]线性布局
- 锁屏界面日期显示异常
- Linux容易被忽视的细节
- echo不换行输出实现进度条
- List的4种迭代方法
- spark模拟密集型计算任务
- Spring:创建Bean的几种方式
- 二十分钟学会Javascript初级语法
- bitmap转换与处理相关工具类,Bitmap与DrawAble与byte[]与InputStream之间的转换