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, ...
随机推荐
- scanf清除缓存区
为什么需要清除scanf缓存区呢?看一个例子: int main() { int a,b; scanf("%d",&a); scanf("%d",&am ...
- Python中 各种数字类型的判别(numerica, digital, decimal)
一. 全角和半角 全角:是指一个全角字符占用两个标准字符(或两个半角字符)的位置. 全角占两个字节. 汉字字符和规定了全角的英文字符及国标GB2312-80中的图形符号和特殊字符都是全角字符.在全角中 ...
- ClassLoader如何加载class?
ClassLoader一个经常出现又让很多人望而却步的词,本文将试图以最浅显易懂的方式来讲解 ClassLoader,希望能对不了解该机制的朋友起到一点点作用. 要深入了解ClassLoader,首先 ...
- Node+Express+MongoDB + Socket.io搭建实时聊天应用实战教程(二)--node解析与环境搭建
前言 本来开始写博客的时候只是想写一下关于MongoDB的使用总结的,后来觉得还不如干脆写一个node项目实战教程实战.写教程一方面在自己写的过程中需要考虑更多的东西,另一方面希望能对node入门者有 ...
- iOS11适配
链接: 你可能需要为你的 APP 适配 iOS 11 iOS11新特性,如何适配iOS11 App界面适配iOS11(包括iPhoneX的奇葩尺寸) iOS 11 安全区域适配总结 iOS 11 sa ...
- iOS埋点统计
链接: iOS无埋点数据SDK实践之路 iOS:无埋点数据SDK实践之路,看完能懂就厉害了 iOS埋点业务方案 ios 无码统计埋点 使用AOP实现iOS应用内的埋点计数 Aspects(AOP) A ...
- 最基本的区块链hello world(python3实现)
源自 用不到 50 行的 Python 代码构建最小的区块链 (英文原文:Let’s Build the Tiniest Blockchain ) ,但是文中的代码是基于python2的,python ...
- C语言事实上不简单:sizeof
问:C语言中一共同拥有多少个keyword? 答:32个. 答不上来的没关系.非常正常.我们玩的是程序的艺术.而不是背数字. 只是这个特殊的数字1<<5也是非常好记的-.-. 问:size ...
- Java int转string 长度不足左补0
最近项目中用到这个需求,我试了两个方法都可以实现 方法一:(推荐) String s=String.format("%010d", 123)//123为int类型,0代表前面要补的 ...
- 如何在IntelliJ IDEA中使用Git .ignore插件忽略不必要提交的文件
参考 https://blog.csdn.net/qq_34590097/article/details/56284935 最近初学Git,而且在使用的IDE是IntelliJ IDEA,发现IDE ...