设置tabhost位于底部的三种方法
来源:互联网 发布:arclive有没有mac 编辑:程序博客网 时间:2024/05/22 08:06
来源:http://www.2cto.com/kf/201309/246359.html
对于Android自带的tabhost组件,是位于页面顶端的,若想让其位于页面底端,在这里提供两种方法。
方法一
1、tabcontent和tabs交换位置
2、设置tabcontent的属性:android:layout_weight="1"
范例
[html]
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="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_weight="1" >
中间部分省略
</FrameLayout>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TabWidget>
</LinearLayout>
</TabHost>
</RelativeLayout>
方法二
1、tabcontent和tabs交换位置
2、将tabs放到一个relativeLayout中,然后加上如下属性:android:layout_alignParentBottom="true"
范例
[html]
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true" >
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
中间部分省略
</FrameLayout>
<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>
</RelativeLayout>
</TabHost>
</RelativeLayout>
方法三
1、将tabcontent和tabs交换位置(tabs移动到LinearLayout标签以下)
2、在tabcontent中加入属性:android:layout_gravity="top"
3、在tabs中加入属性:android:layout_gravity="bottom"
范例
[html] <?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="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>
</RelativeLayout>
0 0
- 【Android】设置tabhost位于底部的三种方法
- 设置tabhost位于底部的三种方法
- 设置tabhost位于底部的三种方法
- 设置tabhost位于底部的三种方法
- 安卓开发设置Tabhost位于底部的方法
- 获得一个位于屏幕底部的tabhost
- android tabhost位于底部
- TabHost三种方法
- tabhost在窗口底部显示的方法
- Android中全屏 取消标题栏,TabHost中设置NoTitleBar的三种方法
- Android中全屏取消标题栏,TabHost中设置NoTitleBar的三种方法
- Android中全屏 取消标题栏,TabHost中设置NoTitleBar的三种方法
- Android中全屏 取消标题栏,TabHost中设置NoTitleBar的三种方法
- Flex 设置TextArea的滚动条 位于底部
- TabHost的底部实现
- 底部tabhost研究三 (TabWidget ,FrameLayout 在TabHost内。TabWidget 和FrameLayout 平行的关系)
- Android中全屏 取消标题栏,TabHost中设置NoTitleBar的三种方法(强制取消黑边)
- Android 位于底部的Tab
- Struts2 --如果想看源码 Struts源码
- UVA11205
- Count the digits of any input integers
- C语言之认识C
- 一些表达式的陷阱
- 设置tabhost位于底部的三种方法
- 插入排序_2.折半插入排序
- 【笔试面试——26】链表06——复杂链表的复制
- 黑马程序员学习6
- 在ajax提交数据时不能乱用php代码
- hadoop2.4.1的ftp服务器搭建
- WIN7 权限配置管理工具 Takeown && Icacls
- 黑马程序员学习7
- HDU2121 Ice_cream’s world II 【最小树形图】+【不定根】