Android 常用UI控件之TabHost(5)Tab栏在底部且在最上层也不盖tab页
tab栏在底部
<TabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="true" >
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- tab1,用include引用tab1的layout -->
<include
android:id="@+id/tab_weixin"
android:layout_width="match_parent"
android:layout_height="match_parent"
layout="@layout/tab_weixin_layout" />
<!-- tab2,用include引用tab2的layout -->
<include
android:id="@+id/tab_contacts"
android:layout_width="wrap_content"
android:layout_height="match_parent"
layout="@layout/tab_contacts_layout" />
...
</FrameLayout>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#E0E0E0"
android:showDividers="none" >
</TabWidget>
</TabHost>
1,如上代码就可以将tab栏放在屏幕底部,TabHost最外层控件,其中FrameLayout是tab页,TabWidget是tab栏,
2,TabWidget在FrameLayout 下就保证tab栏在最上层。
3,但是如果其中的tab页的内容过高,tab栏就会盖住tab页的底部,在TabHost内嵌入一个RelativeLayout 并指定tab栏在底部,且在tab页下面就可,如下:
Tab栏在底部且在最上层也不盖tab页示例
<TabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="true" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@android:id/tabs" > <!-- 注意此句,如果没有此句,当tab1,tab2...过高时,底部会被TabWidget盖住 -->
<!-- tab1,用include可以引用别处的layout -->
<include
android:id="@+id/tab_weixin"
android:layout_width="match_parent"
android:layout_height="match_parent"
layout="@layout/tab_weixin_layout" />
<!-- tab2,用include可以引用别处的layout -->
<include
android:id="@+id/tab_contacts"
android:layout_width="wrap_content"
android:layout_height="match_parent"
layout="@layout/tab_contacts_layout" />
...
</FrameLayout>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#E0E0E0"
android:showDividers="none" >
</TabWidget>
</RelativeLayout>
</TabHost>
其中
android:layout_above="@android:id/tabs" 设置tab页在tab栏上,
android:layout_alignParentBottom="true" 设置tab栏在底部。
TabWidget在FrameLayout下 设置tab栏在最上层。
Android 常用UI控件之TabHost(5)Tab栏在底部且在最上层也不盖tab页的更多相关文章
- Android 常用UI控件之TabHost(2)简单示例
1,布局 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tool ...
- Android 常用UI控件之TabHost(1)TabHost的两种布局方式
TabHost是Android中的tab组件. TabHost布局文件的基本结构 TabHost下有个layout,这个layout中有TabWidget与FrameLayout.TabWidget是 ...
- Android 常用UI控件之TabHost(4)实现当Tab栏有多个tab时,可以左右滑动
<!-- <HorizontalScrollView android:id="@+id/horizontalScrollView1" android:layout_wi ...
- Android 常用UI控件之TabHost(3)在4.0不显示图标的解决方案
1,自定义 TabWidget 上每个tab的view 2,用多个图片
- Android 常用UI控件之Tab控件的实现方案
实现Tab的方式有多种 1,ActionBar有两种模式可以实现,但是已经过期 tab模式tab在顶部,分裂模式tab在底部(同时所有action item都在底部). 2,PagerTitleStr ...
- 【风马一族_Android】第4章Android常用基本控件
第4章Android常用基本控件 控件是Android用户界面中的一个个组成元素,在介绍它们之前,读者必须了解所有控件的父类View(视图),它好比一个盛放控件的容器. 4.1View类概述 对于一个 ...
- [置顶] Android常用适配器控件
Android常用适配器控件 列表控件用于显示数据集合,Android不是使用一种类型的控件管理显示和数据,而是将这两项功能分布用列表控件和适配器来实现.列表控件扩展了android.widget.A ...
- [Android] Android 让UI控件固定于底部的几种方法
Android 让UI控件固定于底部的几种方法1.采用linearlayout布局:android:layout_height="0dp" <!-- 这里不能设置fill_p ...
- widget 常用UI控件介绍
一.单选框 单选框实例程序: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android&q ...
随机推荐
- Shell根据年月日创建文件夹
#!/bin/sh dir_path="/vol/project/log/test/" ..} do #echo "$year" cd $dir_path mk ...
- JS实现图片翻书效果示例代码
js 图片翻书效果. picture.html <html xmlns="http://www.w3.org/1999/xhtml"> <head> ...
- 教你配置linux服务器登陆欢迎信息
登录一台测试机时发现显示PS1前还显了一行’Welcome to Cloudex’的欢迎信息,真丫牛B.在linux中,设置/etc/issue和/etc/motd文件即可实现这样的登录欢迎信息. 登 ...
- 破解网络投票IP限制、验证码限制、COokie限制、Seesion限制的方法!(转)
顾名思义,网络投票就是在网络上进行的投票活动,但和其他类型的投票不同的是:网络投票是建立在网络投票系统上的,而结果完全由程序输出,无需人工参与.这既是网络投票系统的优点也是其缺点,没有了人工的参与,其 ...
- (转载)SQL语句,纵列转横列
SQL语句,纵列转横列 Feed: 大富翁笔记 Title: SQL语句,纵列转横列 Author: wzmbox Comments sTable.db库位 货物编号 库存数1 0101 501 01 ...
- 用pycharm开发django项目示例
pycharm开发django工程(一) 在pycharm(企业版)中新建Django工程,注意使用虚拟环境 创建成功后,在pycharm显示的工程目录结构如下: 打开pycharm的Termina ...
- Python学习笔记2——模块的发布
1.为模块nester创建文件夹nester,其中包含:nester.py(模块文件): """这是"nester.py"模块,提供了一个名为prin ...
- MySQL创建数据库[保存mojo格式的数据库]已经常用的utf8格式数据库
一.创建最新编码utf8mb4格式的库: CREATE DATABASE IF NOT EXISTS yourdbname CHARACTER SET utf8mb4 COLLATE utf8mb4_ ...
- 第2章 Git安装与设置
2.1 安装Git 略 2.2 设置Git 通过命令git config,用户可以把此类信息提供给本地版本库. 全局变量:在这台计算机上使用任何Git版本库时,这些全局变量的值都起作用.在相关命令中加 ...
- P3381: [Usaco2004 Open]Cave Cows 2 洞穴里的牛之二
这题..思维上远没有上一题复杂,是一个裸的RMQ..利用倍增就可以解决了. var n,q,i,j,f,t,c:longint; a:array[..,..] of longint; function ...