线性布局LinearLayout的使用

来源:互联网 发布:知乎回答问题 出错了 编辑:程序博客网 时间:2024/05/17 22:32
LinearLayout布局是Android中常用的布局方式,是一个ViewGroup以线性方向显示其子view元素。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="horizontal" >    <Button        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_weight="1"        android:text="Button1" />    <Button        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_weight="1"        android:text="Button2" />    <Button        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_weight="1"        android:text="Button3" /></LinearLayout>
其中layout_width,layout_height示_weight是属性,分别控件的宽度,高度和比例。显示效果如图:![显示效果](http://img.blog.csdn.net/20160227173942266)
0 0
原创粉丝点击