Android学习 (六) 常见布局之线性布局

来源:互联网 发布:华为交换机查mac ip 编辑:程序博客网 时间:2024/04/28 19:40

1.LinearLayout线性布局

//orientation是定义线性布局的形式的,有垂直和水平可选,下面语句为水平android:orientation="horizontal" 

layout_gravity属性,可以实现定义的控件特殊位置的指定
layout_weight属性,允许我们使用比例来指定控件的大小

<EditText        android:id="@+id/input_msg"        android:layout_width="0dp"        android:layout_height="wrap_content"        android:layout_weight="1"        android:hint="点我试试"        />    <Button        android:id="@+id/button_1"        android:layout_width="0dp"        android:layout_height="wrap_content"        android:layout_weight="1"        android:text="send"        />

//在水平方向上,先把所有的layout_weight相加,再根据各自的所占比例来分配位置.
//在竖直方向上只要做相应的改动就行

0 0
原创粉丝点击