将TabHost选项卡置底

来源:互联网 发布:nginx配置ssl证书 编辑:程序博客网 时间:2024/04/30 06:24

想要将TabHost置底,那么只需要在xml文件中TabWidget用relativeLayout包裹,并且设置android:layout_alginParentBottom="true"就可以,具体如下:

<?xml version="1.0" encoding="utf-8"?>  
<LinearLayout  
    xmlns:android="http://schemas.android.com/apk/res/android"  
    android:orientation="vertical"  
    android:layout_width="fill_parent"  
    android:layout_height="fill_parent">  
    <TabHost  
        android:id="@+id/tabhost"  
        android:layout_width="fill_parent"  
        android:layout_height="fill_parent">  
        <FrameLayout  
            android:id="@android:id/tabcontent"  
            android:layout_width="fill_parent"  
            android:layout_height="fill_parent"  
            android:paddingBottom="62px">  
            <AnalogClock  
                android:id="@+id/tab1"  
                android:layout_width="fill_parent"  
                android:layout_height="fill_parent"  
                android:layout_centerHorizontal="true" />  
            <Button  
                android:id="@+id/tab2"  
                android:layout_width="fill_parent"  
                android:layout_height="fill_parent"  
                android:text="A semi-random button" />  
        </FrameLayout>  
        <RelativeLayout  
            android:layout_width="fill_parent"  
            android:layout_height="fill_parent">  
            <TabWidget  
                android:id="@android:id/tabs"  
                android:layout_alignParentBottom="true"  
                android:layout_width="fill_parent"  
                android:layout_height="60px" />  
        </RelativeLayout>  
    </TabHost>  
</LinearLayout>