Android TabWidget底部显示
TabHost控件默认使用LinearLayout包裹TabWidget和FrameLayout,布局文件如下:
- <TabHost xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@android:id/tabhost"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
- <TabWidget
- android:id="@android:id/tabs"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
- </TabWidget>
- <FrameLayout
- android:id="@android:id/tabcontent"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
- </FrameLayout>
- </LinearLayout>
- </TabHost>
这样TabWidget显示在顶部,如果想把TabWidget放到底部有三种方式。
方式一:将TabHost中默认的LinearLayout换成RelativeLayout,并给TabWidget添加Android:layout_alignParentBottom="true"
- <TabHost xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/tabhost"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_alignParentLeft="true"
- android:layout_alignParentTop="true" >
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- <TabWidget
- android:id="@android:id/tabs"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true">
- </TabWidget>
- <FrameLayout
- android:id="@android:id/tabcontent"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
- </FrameLayout>
- </RelativeLayout>
- </TabHost>
方式二:1、将LinearLayout中TabWidget和FrameLayout交换位置
2、设置FrameLayout的属性:android:layout_weight="1" android:layout_height="0dp"
- <p><TabHost xmlns:android="<a target=_blank href="http://schemas.android.com/apk/res/android">http://schemas.android.com/apk/res/android</a>"
- android:id="@+id/tabhost"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_alignParentLeft="true"
- android:layout_alignParentTop="true" ></p><p> <LinearLayout
- 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="0dp"
- android:layout_weight="1" >
- </FrameLayout>
- <TabWidget
- android:id="@android:id/tabs"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true">
- </TabWidget>
- </LinearLayout>
- </TabHost></p>
方式三:1、将TabWidget移动到LinearLayout标签以下
2、在FrameLayout中加入属性:android:layout_gravity="top"
3、在TabWidget中加入属性:android:layout_gravity="bottom"
- <TabHost xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/tabhost"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_alignParentLeft="true"
- android:layout_alignParentTop="true" >
- <LinearLayout
- 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_gravity="top" >
- </FrameLayout>
- </LinearLayout>
- <TabWidget
- android:id="@android:id/tabs"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom">
- </TabWidget>
- </TabHost>
以上三种方式在Android4.2下测试通过。
Android TabWidget底部显示的更多相关文章
- android BottomNavigationView 底部显示3个以上的item
你现在可以用app:labelVisibilityMode="[labeled, unlabeled, selected, auto] labeled 所有的标签都是可见的. unlabel ...
- Android应用底部导航栏(选项卡)实例
现在很多android的应用都采用底部导航栏的功能,这样可以使得用户在使用过程中随意切换不同的页面,现在我采用TabHost组件来自定义一个底部的导航栏的功能. 我们先看下该demo实例的框架图: 其 ...
- Android自定义底部带有动画的Dialog
Android自定义底部带有动画的Dialog 效果图 先看效果图,是不是你想要的呢 自定义Dialog package --.view; import android.app.Dialog; imp ...
- dialog自适应大小、固定大小、底部显示
创建一个从底部显示的对话框 if (dialog == null) { dialog = new Dialog(context, R.style.theme_from_bottom); View vi ...
- Android动态控制状态栏显示和隐藏
记得之前有朋友在留言里让我写一篇关于沉浸式状态栏的文章,正巧我确实有这个打算,那么本篇就给大家带来一次沉浸式状态栏的微技巧讲解. 其实说到沉浸式状态栏这个名字我也是感到很无奈,真不知道这种叫法是谁先发 ...
- Android 全屏显示
Android全屏显示: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInst ...
- Android之垂直显示TextView
Android之垂直显示TextView 1因为界面需求原因,需要TextView垂直显示,话不多说,看代码,我也是搜的例子,在此感谢写这个例子的大神,在此做个笔记和分享给大家 2.用到了自定义控件的 ...
- Android 修改底部导航栏navigationbar的颜色
Android 修改底部导航栏navigationbar的颜色 getWindow().setNavigationBarColor(Color.BLUE); //写法一 getWindow().set ...
- Android在ListView显示图片(重复混乱闪烁问题)
Android在ListView显示图片(重复混乱闪烁问题) 1.原因分析 ListView item缓存机制: 为了使得性能更优,ListView会缓存行item(某行相应的View). ListV ...
随机推荐
- MySQL MMM 双主在Failover时挂起
两台MySQL服务器,版本Percona 5.5.35,配置双主,装在Centos 6.4下 Master1 db1,172.21.120.160(真实IP),172.21.120.173(Writ ...
- Qt qml 模拟iphone slide to unlock 的聚光动画文字效果
模拟iphone slide to unlock 的聚光动画文字效果 /底层放淡文字 /前景放高亮文字+半透明遮罩 /动画移动遮罩 Author: surfsky.cnblogs.c ...
- Cellebrite UFED 5.1 发布,全面支持三星 S6 S6 Edge Note5 HUAWEI series
世界级取证公司Cellebrite 昨天发布了最新的 UFED 5.1 系统更新,4PC全面支持三星S6,S6EDGE NOTE5 以及HUAWEI,LG系列恢复,锁屏密码XX!下面是部分截图 有需要 ...
- uboot补丁的使用
在u-boot跟linux内核(台湾叫核心)编译过程中, 有个东西叫补丁, 其实通过某些补丁文件, 可以知道它对原始的版本做过哪些修改, 比前面那个帖子的挨个文件挨个文件的修改, 显得要高级那么一丢丢 ...
- 在oneAPM参加第一个项目小结
从12月15日开始加入进入oneAPM的第二个项目,也是我真正近距离接触项目的一次吧,到今天差不多接近尾声了,很高心能和大家一起共同改造这个项目,虽然说我做的贡献并不大,但是身临项目真的会收获很多体会 ...
- 山东省第七届ACM省赛------Julyed
Julyed Time Limit: 2000MS Memory limit: 65536K 题目描述 Julyed is preparing for her CET-6. She has N wor ...
- input标签file的value属性IE兼容性问题
在IE中input标签file的value属性是只读的,不能通过js来改变,如下代码在IE中就是无效的: var input = document.getElementById('file'); in ...
- Concurrency vs. Parallelism
http://getakka.net/docs/concepts/terminology Terminology and Concepts In this chapter we attempt to ...
- BASH比较大小
- tomcat部署web项目的3中方法
1.直接把项目复制到Tomcat安装目录的webapps目录中,这是最简单的一种Tomcat项目部署的方法,也是初学者最常用的方法. 2.在tomcat安装目录中有一个conf文件夹,打开此文件夹,其 ...