android中的布局--嵌套布局
2013-08-21 19:29
267 查看
在同一个Activity中要实现多种不同的布局类型或者同种布局类型的不同方式,就需要用到嵌套的方式来实现。
例子程序实现:
(1)整个Activity最外层采用垂直方向的LinearLayout线性布局。
(2)套用两个LinearLayout线性布局,上面的是水平方向的,下面的是垂直方向的。
(3)上下的LinearLayout内各放置4个空间
[java] view
plaincopy
<span style="color:#339933"></span><pre name="code" class="html"><?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
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<TextView
android:text="red"
android:gravity="center_horizontal"
android:background="#aa0000"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"/>
<TextView
...../>
<TextView
...../>
<TextView
...../>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<TextView
...../>
<TextView
...../>
<TextView
...../>
<TextView
...../>
</LinearLayout>
</LinearLayout></pre><span style="color:rgb(80,67,61); font-family:Arial,Helvetica,Georgia,sans-serif; font-size:14px; line-height:25px">其实就是按照设计思路中的布局要求,直接在上层布局中嵌套使用新的布局即可。</span><br><br>
文章转自:http://blog.csdn.net/wangchenggong88/article/details/6655235
例子程序实现:
(1)整个Activity最外层采用垂直方向的LinearLayout线性布局。
(2)套用两个LinearLayout线性布局,上面的是水平方向的,下面的是垂直方向的。
(3)上下的LinearLayout内各放置4个空间
[java] view
plaincopy
<span style="color:#339933"></span><pre name="code" class="html"><?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
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<TextView
android:text="red"
android:gravity="center_horizontal"
android:background="#aa0000"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"/>
<TextView
...../>
<TextView
...../>
<TextView
...../>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<TextView
...../>
<TextView
...../>
<TextView
...../>
<TextView
...../>
</LinearLayout>
</LinearLayout></pre><span style="color:rgb(80,67,61); font-family:Arial,Helvetica,Georgia,sans-serif; font-size:14px; line-height:25px">其实就是按照设计思路中的布局要求,直接在上层布局中嵌套使用新的布局即可。</span><br><br>
文章转自:http://blog.csdn.net/wangchenggong88/article/details/6655235
相关文章推荐
- Android 如果布局中有ScrollView和Fragment或者带有滚动条的布局进行嵌套,布局加载完成页面无法定位到顶部的情况
- Android应用的LinearLayout中嵌套RelativeLayout的布局用法
- Android应用的LinearLayout中嵌套RelativeLayout的布局用法
- 解决android FragmentTabHost + viewpager + fragment 嵌套布局切换出现白屏什么都没有问题
- Android中多层动态嵌套布局的实现
- Android中多层动态嵌套布局的实现
- Android:LinearLayout布局和其嵌套运用举例
- Android一个布局文件嵌套另一个布局文件的方法
- Android布局管理器的嵌套
- Android滚动的布局嵌套滚动的布局会出现问题
- 从零开始学android<使用嵌套布局实现计算器界面.十七.>
- Android 布局嵌套
- Android 动态生成布局 (多层嵌套)
- Android 5.0新控件 AppBarLayout | 嵌套布局 介绍及使用详情
- Android基于基于布局嵌套的页面导航实现
- Android小知识——ScrollView内的内部嵌套LinearLayout布局导致滑动条占位置
- Android fragment嵌套fragment 子fragment控制父对象改变布局
- Android 嵌套布局简析
- Android中多层动态嵌套布局的实现
- Android中多层动态嵌套布局的实现