0

我在布局底部创建了一个 TabWidget。选项卡小部件中有 5 个选项卡。但是这些标签并没有占据整个宽度。xml文件如下:

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/tabHost1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
     <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="5dp">

        <FrameLayout
           android:id="@android:id/tabcontent"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           android:padding="5dp"
           android:layout_weight="1"/>

        <TabWidget
           android:id="@android:id/tabs"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           android:layout_weight="0"
           android:layout_marginBottom="-4dp"/>

    </LinearLayout>


</TabHost> 

请帮忙。

4

2 回答 2

0

为什么不尝试使用 RelativeLayout 而不是 LinearLayout

<RelativeLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="5dp">
于 2012-10-29T11:28:10.387 回答
0

我相当确定从您的线性布局和框架布局中删除 android:padding="5dp" 标记应该可以满足您的需求...

所以你会看这个

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/tabHost1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
     <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

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

        <TabWidget
           android:id="@android:id/tabs"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           android:layout_weight="0"
           android:layout_marginBottom="-4dp"/>

    </LinearLayout>


</TabHost> 
于 2012-11-09T02:23:56.993 回答