LinearLayOut学习
提供了控件的水平或垂直排列的模型。
如果使用android:layout_weight 可以控制控件在容器中的相对大小。
如果页面有两个控件,
1.页面布局是horizontal,那么这两个控件将在垂直方向平分占据
2.页面布局是vertical,那么这两个控件将在水平方向平分占据
例子:下面的例子表示上下两个linearlayout,上面这个平分四等份,垂直布局放置4个textview,下面这个平分四等分,水平布局放置4个textview
<?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 xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_weight="1">
<TextView android:text="红色" android:gravity="center_vertical|center_horizontal"
android:id="@+id/tv1" android:layout_width="wrap_content"
android:layout_height="fill_parent" android:layout_weight="1"
android:background="#aa0000" />
<TextView android:text="绿色" android:gravity="center_horizontal"
android:id="@+id/tv2" android:layout_width="wrap_content"
android:layout_height="fill_parent" android:layout_weight="1"
android:background="#00aa00" />
<TextView android:text="蓝色" android:gravity="center|bottom"
android:id="@+id/tv3" android:layout_width="wrap_content"
android:layout_height="fill_parent" android:layout_weight="1"
android:background="#0000aa" />
<TextView android:text="黄色"
android:id="@+id/tv4" android:layout_width="wrap_content"
android:layout_height="fill_parent" android:layout_weight="1"
android:background="#aaaa00" />
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_weight="1">
<TextView android:text="第一行"
android:id="@+id/tv5" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_weight="1"
/>
<TextView android:text="第二行"
android:id="@+id/tv6" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_weight="1"
/>
<TextView android:text="第三行"
android:id="@+id/tv7" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_weight="1"
/>
<TextView android:text="第四行"
android:id="@+id/tv8" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_weight="1"
/>
</LinearLayout>
</LinearLayout>
分享到:
相关推荐
[Android开发从零开始].10.LinearLayout学习
Android应用源码之10._LinearLayout学习.zip项目安卓应用源码下载Android应用源码之10._LinearLayout学习.zip项目安卓应用源码下载 1.适合学生毕业设计研究参考 2.适合个人学习研究参考 3.适合公司开发项目技术参考
Android 应用开发源码 参考与学习使用
android 源码学习. 资料部分来源于合法的互联网渠道收集和整理,供大家学习参考与交流。本人不对所涉及的版权问题或内容负法律责任。如有侵权,请通知本人删除。感谢CSDN官方提供大家交流的平台
免责声明:资料部分来源于合法的互联网渠道收集和整理,部分自己学习积累成果,供大家学习参考与交流。收取的费用仅用于收集和整理资料耗费时间的酬劳。 本人尊重原创作者或出版方,资料版权归原作者或出版方所有,...
android linearlayout 学习
Android应用源码开发Demo,主要用于毕业设计学习。
[Android开发从零开始].10.LinearLayout学习.mp4 42.7MB [Android开发从零开始].11.AbsoluteLayout和FrameLayout.mp4 34.6MB [Android开发从零开始].12.RelativeLayout.mp4 57.7MB [Android开发从零开始].12....
Android源码LinearLayout实例,经典代码,是学习Android的好东西
Android中线性布局LinearLayout的特点.pdf 学习资料 复习资料 教学资源
可以拖拽排序的LinearLayout.rar,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。
Android开发学习23】界面布局之线性布局LinearLayout代码
Android学习笔记(八):Activity-OpenMenu和LinearLayout
主要给大家介绍了关于Android自定义LinearLayout但布局显示不完整的解决方法,文中通过示例代码介绍的非常详细,对大家具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧。
智能家居系统 线性布局LinearLayout.doc 学习资料 复习资料 教学资源
android8系统LinearLayout原代码,供大家在自定义viewGroup组件时,可以做为参考,也可以学习一下系统UI底层的实现
LinearLayout是线性布局控件,它包含的子控件将以横向或竖向的方式排列,按照相对位置来排列所有的widgets或者其他的...有的时候,我们需要想获取LinearLayout宽高,下面通过这篇文章来跟着小编一起学习学习吧。
可升缩LinearLayout.zip项目安卓应用源码下载可升缩LinearLayout.zip项目安卓应用源码下载 1.适合学生毕业设计研究参考 2.适合个人学习研究参考 3.适合公司开发项目技术参考
Android移动应用开发线性布局LinearLayout的常用属性.pdf 学习资料 复习资料 教学资源