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页的更多相关文章

  1. Android 常用UI控件之TabHost(2)简单示例

    1,布局 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tool ...

  2. Android 常用UI控件之TabHost(1)TabHost的两种布局方式

    TabHost是Android中的tab组件. TabHost布局文件的基本结构 TabHost下有个layout,这个layout中有TabWidget与FrameLayout.TabWidget是 ...

  3. Android 常用UI控件之TabHost(4)实现当Tab栏有多个tab时,可以左右滑动

    <!-- <HorizontalScrollView android:id="@+id/horizontalScrollView1" android:layout_wi ...

  4. Android 常用UI控件之TabHost(3)在4.0不显示图标的解决方案

    1,自定义 TabWidget 上每个tab的view 2,用多个图片

  5. Android 常用UI控件之Tab控件的实现方案

    实现Tab的方式有多种 1,ActionBar有两种模式可以实现,但是已经过期 tab模式tab在顶部,分裂模式tab在底部(同时所有action item都在底部). 2,PagerTitleStr ...

  6. 【风马一族_Android】第4章Android常用基本控件

    第4章Android常用基本控件 控件是Android用户界面中的一个个组成元素,在介绍它们之前,读者必须了解所有控件的父类View(视图),它好比一个盛放控件的容器. 4.1View类概述 对于一个 ...

  7. [置顶] Android常用适配器控件

    Android常用适配器控件 列表控件用于显示数据集合,Android不是使用一种类型的控件管理显示和数据,而是将这两项功能分布用列表控件和适配器来实现.列表控件扩展了android.widget.A ...

  8. [Android] Android 让UI控件固定于底部的几种方法

    Android 让UI控件固定于底部的几种方法1.采用linearlayout布局:android:layout_height="0dp" <!-- 这里不能设置fill_p ...

  9. widget 常用UI控件介绍

        一.单选框 单选框实例程序: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android&q ...

随机推荐

  1. 【C#高级编程(学习与理解)】1.1 C#与.NET的关系

    1.C#语言不能孤立使用,而必须和.NET Framework一起考虑.C#编译器专门用于.NET,这表示用C#编写的所有代码总是在.NET Framework中运行. 2.C#就其本身而言只是一种语 ...

  2. MySQL EER反向建表

    Database > Synchronize Model... Choose Stored Connection Select the Schemata Choose which to upda ...

  3. coreseek安装使用

    本文引自:http://www.phperz.com/article/14/0615/95.html sphinx的安装使用,其实都是大同小异,以下以 coreseek安装为例Coreseek 是一款 ...

  4. Setfocus - IE 需要使用setTimeout

    setTimeout(function () { $('#controlid').focus(); }, 100); document.getElementById('filterPopupInput ...

  5. a标签点击后的虚线框问题

    以前一直用的方法都是: a {outline: none;star:expression(this.onFocus=this.blur());} 后来发现有瑕疵,不完美.体现在页面调用JS动作比较频繁 ...

  6. 针对PIL中ImageDraw.py报错的解决方案

    linux mint 13开始就发现这个问题了,一直不知道怎么解决,今天突然发现了解决方案,来分享给大家 下面是修改对比,自己根据修改,这个是系统文件,需要root权限,路径/usr/lib/pyth ...

  7. CLSID {91493441-5A91-11CF-8700-00AA0060263B}错误

    最近遇到一个棘手的问题,在C#中处理PPT转HTML的过程中需要用到COM组件,按照往常的设置如下: 1. Start->Run->DCOMCNFG->Component Servi ...

  8. 使用Schtasks命令的注意事项

    在使用Schtasks命令时遇到了两个棘手的问题,耗费了一点时间,出现这个问题的时候查找网络资源也找不到真正的解决方案,最后还是自己悟出来了原因,所以在此把这些问题记录下来.如下: 服务器环境:win ...

  9. hibernate映射文件基础

    一.利用hibernate的eclipse插件快速生成实体类与配置文件的方法 1.首先下载安装和自己的eclipse版本配套的hibernate tools,如果是Myeclipse,在/readme ...

  10. eclipse 书签

    虽然eclipse有back to和forward两个功能帮助我们阅读代码,但有时候代码一层一层看下去后,会忘了自己最初的起点. 因此想到了eclipse的书签bookmark功能. 首先,添加书签. ...