Android:在TabActivity下添加视图

时间:2011-01-23 19:36:15

标签: android layout tabview

所以我有一个带有2个标签的标签活动。在这些下面我想有第二个观点。 目前我可以将视图放在最后,但它仍然与当前可见选项卡末尾的任何内容重叠。有没有人知道如何在标签下方获取第二个视图而不是重叠其内容的结尾?

例如,如果视图只是一个textview,我的布局如下所示:

<?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="fill_parent"
    android:layout_height="fill_parent">

        <LinearLayout android:id="@+id/linearLayout"
            android:orientation="vertical"
            android:layout_width="fill_parent" 
            android:layout_height="fill_parent">

            <TabWidget android:id="@android:id/tabs"
                android:layout_width="fill_parent" 
                android:layout_height="wrap_content" />

            <FrameLayout android:id="@android:id/tabcontent"
                android:layout_width="fill_parent" 
                android:layout_height="fill_parent"/>

        </LinearLayout>
    </TabHost>

    <RelativeLayout android:id="@+id/InnerRelativeLayout" 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true">

        <TextView android:id="@+id/EndView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="At the end of the screen"/>

        </RelativeLayout>
</RelativeLayout>

1 个答案:

答案 0 :(得分:0)

使用android:below="@id/tabhost"

<?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 ...>
        ...
    </TabHost>

    <RelativeLayout android:id="@+id/InnerRelativeLayout" 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:below="@id/tabhost"><!-- LOOK HERE  -->

        <TextView android:id="@+id/EndView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="At the end of the screen"/>

        </RelativeLayout>
</RelativeLayout>