Android 如何使片段tabhost的内容占据全部宽度?

Android 如何使片段tabhost的内容占据全部宽度?,android,fragment,fragment-tab-host,Android,Fragment,Fragment Tab Host,我已经将ImageView、fragment tabhost和ImageButton放置在我创建的一个栏上,我希望tabhost的内容占据整个宽度,但是我得到的只是如图所示。我到处找,但找不到解决办法 XML代码如下所示 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_h

我已经将ImageView、fragment tabhost和ImageButton放置在我创建的一个栏上,我希望tabhost的内容占据整个宽度,但是我得到的只是如图所示。我到处找,但找不到解决办法

XML代码如下所示

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="#2D5990"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.105"
        android:src="@drawable/ic_launcher"
        android:layout_marginLeft="2dp"
        android:paddingTop="5dp"
        android:paddingBottom="5dp" /> 

    <android.support.v4.app.FragmentTabHost
        android:id="@android:id/tabhost"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.5" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <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="0dp"
                android:layout_weight="1" />
        </LinearLayout>

    </android.support.v4.app.FragmentTabHost>

    <ImageButton
            android:id="@+id/imageButton1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:contentDescription="No Desc"
            android:padding="3dp"
            android:gravity="right" 
            android:layout_weight="0.2"
            android:src="@drawable/ic_launcher" />     
 </LinearLayout>
对不起,我现在已经更新了代码


如果在布局中使用ImageView和ImageButton,则片段选项卡Host的内容不会占据全部宽度

如果希望fragment tabhost占据版面的全部宽度,则只能使用android.support.v4.app.FragmentTabHost

因此,请尝试从布局中删除ImageView和ImageButton


我希望这能对您有所帮助。

谢谢您的回答!经过很长时间才得到答案!