Android--->LinearLayout页面布局方式
2016-07-30 22:22
513 查看
main.xml布局方式
<?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"> <!-- 第一个布局,layout_weight="1"空间占比例为1,horizontal水平布局 --> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1"> <!-- 在第一个布局区域中,第一个布局,gravity文字位置,这里表示居中,所占比例为1 --> <TextView android:text="红色" android:gravity="center_horizontal|center_vertical" android:background="#aa0000" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1"/> <!-- 在第一个布局区域中,第一个布局,gravity文字位置,这里表示水平居中,所占比例为1 --> <TextView android:text="绿色" android:gravity="center_horizontal" android:background="#00aa00" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1"/> <!-- 在第一个布局区域中,第二个布局,gravity文字位置,这里表示中下,所占比例为1 --> <TextView android:text="蓝色" android:gravity="center|bottom" android:background="#0000aa" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1"/> <!-- 在第一个布局区域中,第三个布局,gravity文字位置,这里表示下,默认为左边,所占比例为1 --> <TextView android:text="黄色" android:gravity="bottom" android:background="#aaaa00" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1"/> </LinearLayout> <!-- 第二个布局,layout_weight="1"空间占比例为1,此时只有两个LinearLayout,表示分半,horizontal水平布局 --> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1"> <TextView android:text="第一行" android:textSize="15sp" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"/> <TextView android:text="第二行" android:textSize="15sp" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"/> <TextView android:text="第三行" android:textSize="15sp" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"/> <TextView android:text="第四列" android:textSize="15sp" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"/> </LinearLayout> </LinearLayout>
相关文章推荐
- Android六大布局的介绍 Android开发布局:.xml 页面排版 1.线性布局(LinearLayout) LinearLayout是线性不布局控件,它包含的子控件将以横向或者竖向的方式
- Android五种布局方式——LinearLayout、RelativeLayout、TableLayout....(四)
- android 较高版本,页面分割线实现LinearLayoutCompat布局简单事例
- Android Layout研究 <三> View的布局方式及实例
- Android--布局方式(LinearLayout)学习
- Android LinearLayout及TextView的布局方式
- Android课堂笔记——LinearLayout和RelativeLayout常用的两种布局方式
- Android实现计算器布局(四种布局方式)之LinearLayout线性布局
- Android------>TableLayout表格布局方式
- Android---->RelativeLayout相对对齐方式布局
- 更改android创建工程的布局RelativeLayout-->LinearLayout
- Android Layout布局使用总结Android中常用的5大布局方式有以下几种: 线性布局(LinearLayout):按照垂直或者水平方向布局的组件。 帧布局(FrameLayout):组件从
- android 较高版本,页面分割线实现LinearLayoutCompat布局简单事例
- Android--布局方式(LinearLayout)学习
- Android布局控件之LinearLayout详解
- android布局之LinearLayout
- android开发布局一_线性布局(LinearLayout)
- Android开发教程 --- 布局(线性布局 Linear Layout )(相对布局 Relative Layout)
- Android布局控件之LinearLayout详解
- Android布局方式之表格布局管理器(TableLayout)