Android:LinearLayout中的FrameLayout

时间:2015-06-29 09:14:01

标签: android android-layout

我正在尝试构建一个TabHost安卓应用程序。我开发了这种布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TabHost
        android:id="@android:id/tabhost"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <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="fill_parent">
            </FrameLayout>

            <HorizontalScrollView
                android:id="@+id/scroll"
                android:layout_width="match_parent"
                android:layout_height="70dp"
                android:layout_gravity="bottom"
                android:background="@drawable/navigation_bar_background"
                android:fillViewport="true"
                android:scrollbarStyle="insideOverlay"
                android:scrollbars="none">

                <TabWidget
                    android:id="@android:id/tabs"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:orientation="horizontal"
                    android:tabStripEnabled="true" >
                </TabWidget>
            </HorizontalScrollView>
        </LinearLayout>
    </TabHost>

</LinearLayout>

出于某种原因,@ id / tabcontent元素涵盖了所有手机屏幕,并且不希望为@id / scroll留出空间。为什么LinearLayout不起作用?

1 个答案:

答案 0 :(得分:0)

如果您希望@ id / scroll始终存在, 将您的xml更改为此

<FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"

&GT;