-
对于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" ><TabHostandroid:id="@android:id/tabhost"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_alignParentLeft="true"android:layout_alignParentBottom="true" ><LinearLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical" ><FrameLayoutandroid:id="@android:id/tabcontent"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_weight="1" >中间部分省略</FrameLayout><TabWidgetandroid: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" ><TabHostandroid:id="@android:id/tabhost"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_alignParentLeft="true"android:layout_alignParentBottom="true" ><FrameLayoutandroid:id="@android:id/tabcontent"android:layout_width="match_parent"android:layout_height="match_parent" >中间部分省略</FrameLayout><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="match_parent" ><TabWidgetandroid: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" ><TabHostandroid:id="@android:id/tabhost"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_alignParentBottom="true"android:layout_alignParentLeft="true" ><LinearLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical" ><FrameLayoutandroid:id="@android:id/tabcontent"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_gravity="top">中间部分省略</FrameLayout></LinearLayout><TabWidgetandroid:id="@android:id/tabs"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_gravity="bottom" ></TabWidget></TabHost></RelativeLayout>
-
设置tabhost位于底部的三种方法
最新推荐文章于 2016-04-08 11:04:28 发布