【问题标题】:Android: Adding a View underneath a TabActivityAndroid:在 TabActivity 下添加视图
【发布时间】:2011-06-14 03:25:06
【问题描述】:

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

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

<?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>

【问题讨论】:

    标签: android layout tabview


    【解决方案1】:

    使用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>
    

    【讨论】:

    • 为此我得到“错误:在包'android'中找不到属性'below'的资源标识符”。你的意思是“android:layout_below="@+id/tabhost"”吗?如果我这样做,文本视图仍然重叠。
    猜你喜欢
    • 2012-01-04
    • 1970-01-01
    • 2011-09-05
    • 1970-01-01
    • 2014-11-05
    • 1970-01-01
    • 2013-09-20
    • 2015-07-29
    • 1970-01-01
    相关资源
    最近更新 更多