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

第一种相对布局:

<?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. MySQL数据库crash的问题分析

    [问题] 生产环境有多台slave服务器,不定期的会crash,下面是error log中的堆栈信息 Thread pointer: 0x7f1e54b26410 Attempting backtra ...

  2. python数据分析---第04章 NumPy基础:数组和矢量计算

    NumPy(Numerical Python的简称)是Python数值计算最重要的基础包.大多数提供科学计算的包都是用NumPy的数组作为构建基础. NumPy的部分功能如下: ndarray,一个具 ...

  3. Spring 注解@Transactional readOnly=true

    引子 今天下班后,以前同事小胖问我Spring  Service类中的注解@Transactional readOnly=true的作用.做为他眼中的高人,我自然要装下A-C.居然想都没有想就说是注解 ...

  4. 2、函数y=f(x)

    /* Note:Your choice is C IDE */ #include "stdio.h" /* 3.函数y=f(x)可表示为: */ void main() { int ...

  5. unity中尽量规避的C#写法

    首先想到的也就是重名的问题. 创建C#脚本的时候,引擎会搜索所有的文件夹里已有的C#脚本,若已经存在这个名字的脚本文件,那么系统就会报错:    再者,类名和方法名不能相同,理解来就是,方法名和类名相 ...

  6. Chrome上网问题解决记录

    浏览器打开网站缓慢,甚至等待很久后直接烂页面 注意观察浏览器左下角会显示: 正在建立安全连接... 环境: 操作系统:Win10 Chrome版本: 69.x 解决办法:http://bbs.360. ...

  7. 【转】两道面试题,带你解析Java类加载机制(类初始化方法 和 对象初始化方法)

    本文转自 https://www.cnblogs.com/chanshuyi/p/the_java_class_load_mechamism.html 关键语句 我们只知道有一个构造方法,但实际上Ja ...

  8. Android中Local Service最本质的作用是什么?

    把Service等同于thread或process是一个非常常见的误解.需要强调又强调的第一点是,Android的Service是一个Context,并不必然等于一个额外的thread.如果你有仔细看 ...

  9. Xcode 安装ClangFormat 插件

    sudo gem install -n /usr/local/bin update_xcode_plugins 安装ClangFormat git clone https://github.com/t ...

  10. Android Studio下加入百度地图的使用 (一)——环境搭建

    最近有学生要做毕业设计,会使用到定位及地图信息的功能,特此研究了一下,供大家参考,百度定位SDK已经更新到了5.0,地图SDK已经更新到了3.5,但是在AndroidStudio中使用还是存在一些不稳 ...