头部、中部、尾部布局涉及到布局内容自适应,总结两个技巧:

第一种相对布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#fff" > <!--使用相对布局,头部在最顶,底部在最低,中部相对两者中间->
<!--头部-->
<RelativeLayout
android:id="@+id/rlhead"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/main_header_bg"
android:gravity="center" >
</RelativeLayout> <!--中部-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/rlfoot"
android:layout_below="@+id/rlhead"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:background="@color/common_white"
android:orientation="vertical"
android:scrollbars="none" > </LinearLayout> <!--尾部-->
<include
android:id="@+id/rlfoot"
layout="@layout/widget_menu" /> </RelativeLayout>

第二种使用比重:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#fff" > <!--头部-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/main_header_bg"
android:gravity="center" >
</RelativeLayout> <!--使用线性布局,头部在最顶,底部在最低,中部采用比重占剩余比重的全部-->
<!--中部-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/common_white"
android:orientation="vertical"
android:scrollbars="none"
android:layout_weight="1"> </LinearLayout> <!--尾部-->
<include
layout="@layout/widget_menu" /> </LinearLayout>

Android开发(十八)——头部、中部、底部布局技巧的更多相关文章

  1. Android进阶(十八)AndroidAPP开发问题汇总(二)

    Android进阶(十八)AndroidAPP开发问题汇总(二) 端口被占用解决措施: Android使用SimpleAdapter更新ListView里面的Drawable元素: http://ww ...

  2. Android 开发:view的几种布局方式及实践

    View的几种布局显示方法,以后就不会在针对布局方面做过多的介绍.View的布局显示方式有下面几种:线性布局(Linear Layout).相对布局(Relative Layout).表格布局(Tab ...

  3. 【转】Android开发学习笔记:5大布局方式详解

    Android中常用的5大布局方式有以下几种: 线性布局(LinearLayout):按照垂直或者水平方向布局的组件. 帧布局(FrameLayout):组件从屏幕左上方布局组件. 表格布局(Tabl ...

  4. Android开发:View的几种布局及实践

    引言 View的布局显示方式有下面几种:线性布局(Linear Layout).相对布局(Relative Layout).表格布局(Table Layout).网格视图(Grid View).标签布 ...

  5. Android开发关闭虚拟按钮、底部导航条

    在Android开发中,遇到了一系列大大小小的问题,其中一个就是屏蔽底部实体键,我找了很多的博客也尝试了许许多多的方法,但始终不能屏蔽 HOME键,后来看见一篇博客说在Android 4.0以后,屏蔽 ...

  6. Android开发(八)——Android组件

    参考: [1] Android开发教程:理解Intent和Intent Filter.http://liuzhichao.com/p/506.html

  7. android开发(1):底部导航条的实现 | navigation tab | activity的创建

    底部导航条,在iOS中叫tabbar,在android中叫bottombar或bottom navigation,是一个常用的切换页面的导航条. 同样,如果有良好的第三方库,我们应该优先考虑,能用好别 ...

  8. Android开发重点难点:RelativeLayout(相对布局)详解

    https://i.cnblogs.com/EditPosts.aspx?opt=1 重点知识 和线性布局(LinearLayout)一样,RelaiveLayout相对布局也是我们用的比较多的一个布 ...

  9. Android入门(十八)服务

    原文链接:http://www.orlion.ga/674/ 一.定义一个服务 创建一个项目ServiceDemo,然后在这个项目中新增一个名为 MyService的类,并让它继承自 Service, ...

随机推荐

  1. JS-最全的创建对象的方式

    JS最全创建对象方式汇总 1.最简单的方式--创建一个Object实例 var person = new Object(); //创建实例 person.name = "BlueBeginn ...

  2. POJ.3710.Christmas Game(博弈论 树上删边游戏 Multi-SG)

    题目链接 \(Description\) 给定n棵"树",每棵"树"的节点可能"挂着"一个环,保证没有环相交,且与树只有一个公共点. 两人轮 ...

  3. python——描述符

    本文主要介绍描述符的定义,个人的一些理解:什么是数据描述符:什么是非数据描述符:描述符的检测等.希望看完这篇文章后,你对描述符有了更清晰的认识.知道怎么判断一个对象是不是描述符,知道如果定义一个描述符 ...

  4. python 条件语句和基础数据类型

    条件语句 if 条件: pass else: pass 如果1等于1,输出欢迎进入东京热,否则输出欢迎进入一本道 ==: print("欢迎进入东京热") else: print( ...

  5. linux常用服务程序一键安装

    PHP7安装 rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm service php-fpm stop yum remove php5* ...

  6. JSON序列——主从表查询

    JSON序列——主从表查询 客户端代码: procedure TForm1.Button4Click(Sender: TObject); // 主从表 查询 begin var url: TynUrl ...

  7. Win7下MongoDB的安装和使用

    Win7下MongoDB的安装和使用 1.下载: http://www.mongodb.org/downloads 2.安装: 安装目录为 D:\mongodb\MongoDB 2.6 Standar ...

  8. Java全栈程序员之04:Ubuntu下安装MySQL、注册服务及Navcat

    在安装MySQL之前,我们先来介绍一下Ubuntu下软件的安装方式.首先回顾下,我们安装JDK,使用的是后缀名为tar.gz的安装包.安装idea,使用的是tar.gz:那有没有别的安装方式呢? 1. ...

  9. java中关于AtomicInteger的使用

    在Java语言中,++i和i++操作并不是线程安全的,在使用的时候,不可避免的会用到synchronized关键字.而AtomicInteger则通过一种线程安全的加减操作接口.咳哟参考我之前写的一篇 ...

  10. android: 在android studio中使用retrolambda的步骤

    找了各种说明,包括retrolambda官方文档都没有试成功 最后在这个链接中找到答案:http://blog.csdn.net/qq_26819733/article/details/5222565 ...