Android开发(十八)——头部、中部、底部布局技巧
头部、中部、尾部布局涉及到布局内容自适应,总结两个技巧:
第一种相对布局:
<?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开发(十八)——头部、中部、底部布局技巧的更多相关文章
- Android进阶(十八)AndroidAPP开发问题汇总(二)
Android进阶(十八)AndroidAPP开发问题汇总(二) 端口被占用解决措施: Android使用SimpleAdapter更新ListView里面的Drawable元素: http://ww ...
- Android 开发:view的几种布局方式及实践
View的几种布局显示方法,以后就不会在针对布局方面做过多的介绍.View的布局显示方式有下面几种:线性布局(Linear Layout).相对布局(Relative Layout).表格布局(Tab ...
- 【转】Android开发学习笔记:5大布局方式详解
Android中常用的5大布局方式有以下几种: 线性布局(LinearLayout):按照垂直或者水平方向布局的组件. 帧布局(FrameLayout):组件从屏幕左上方布局组件. 表格布局(Tabl ...
- Android开发:View的几种布局及实践
引言 View的布局显示方式有下面几种:线性布局(Linear Layout).相对布局(Relative Layout).表格布局(Table Layout).网格视图(Grid View).标签布 ...
- Android开发关闭虚拟按钮、底部导航条
在Android开发中,遇到了一系列大大小小的问题,其中一个就是屏蔽底部实体键,我找了很多的博客也尝试了许许多多的方法,但始终不能屏蔽 HOME键,后来看见一篇博客说在Android 4.0以后,屏蔽 ...
- Android开发(八)——Android组件
参考: [1] Android开发教程:理解Intent和Intent Filter.http://liuzhichao.com/p/506.html
- android开发(1):底部导航条的实现 | navigation tab | activity的创建
底部导航条,在iOS中叫tabbar,在android中叫bottombar或bottom navigation,是一个常用的切换页面的导航条. 同样,如果有良好的第三方库,我们应该优先考虑,能用好别 ...
- Android开发重点难点:RelativeLayout(相对布局)详解
https://i.cnblogs.com/EditPosts.aspx?opt=1 重点知识 和线性布局(LinearLayout)一样,RelaiveLayout相对布局也是我们用的比较多的一个布 ...
- Android入门(十八)服务
原文链接:http://www.orlion.ga/674/ 一.定义一个服务 创建一个项目ServiceDemo,然后在这个项目中新增一个名为 MyService的类,并让它继承自 Service, ...
随机推荐
- UVa 11059 - Maximum Product 最大乘积【暴力】
题目链接:https://vjudge.net/contest/210334#problem/B 题目大意:Given a sequence of integers S = {S1, S2, . . ...
- Redis分布式锁实现方式(附有正解及错误示例)
一.前言 本文内容主要来自博客:https://wudashan.com/2017/10/23/Redis-Distributed-Lock-Implement/,本文用于归纳总结及笔记用途,如有需要 ...
- go语言学习-函数
函数声明 函数声明包括函数名,形参列表,返回值列表(可选),函数体组成 func test(parameters) (returns) { // ... } 其中 parameters 就是函数的形参 ...
- Scratch儿童项目式编程—捉迷藏游戏 Scratch children project programming - hide-and-seek game
Scratch儿童项目式编程—捉迷藏游戏 Scratch children project programming - hide-and-seek game 作者:韩梦飞沙 Author:han_me ...
- luogu P4178 Tree
题目链接 luogu P4178 Tree 题解 点分治 代码 // luogu-judger-enable-o2 #include<cstdio> #include<algorit ...
- 线性代数与Python
1.向量1.1向量例子1.2向量加法与减法1.3向量的乘法2.矩阵2.1矩阵例子2.2矩阵的形状2.3矩阵的创建函数 1.向量 向量是指可以加总(以生成新的向量),可以乘以标量(即数字),也可以生成新 ...
- 潭州课堂25班:Ph201805201 第十二课 new方法,定制属性访问,描述符与装饰器 (课堂笔记)
1,new方法: 类每次实例化时都会创建一个新的对象, class Textcls: # cls 是指类本身, def __new__(cls, *args, **kwargs): # 在 __ini ...
- TVTK库的安装
1.在网址为:http://www.lfd.uci.edu/~gohlke/pythonlibs/ 里下载以下内容: VTK-7.1.1-cp36-cp36m-win_amd64.whlnumpy-1 ...
- linux 配置sendmail支持php mail 函数
参考自:http://blog.csdn.net/shiningstarpxx/article/details/41008325 http://blog.sina.com.cn/s/blog_65c8 ...
- 喵哈哈村的魔法考试 Round #11 (Div.2) 题解
喵哈哈村的星星与月亮(一) 打表发现答案就等于a*b%mod 注意a*b可能爆longlong #include<bits/stdc++.h> using namespace std; c ...