如何在XML布局中设置android选项卡的宽度?

如何在XML布局中设置android选项卡的宽度?,android,android-layout,Android,Android Layout,我已经看到了,但是我想知道如何在XML文件中实现这一点。。我的目标是在顶部有一组选项卡,使用所有可用的屏幕宽度。我现在不知道该怎么做。设置tabhost的布局宽度以填充父对象并不能达到这个目的。当我使用Tab时,我通常只是通过将android可见性设置为Goe来隐藏tabwidget标记 并添加按钮作为选项卡按钮,如 <?xml version="1.0" encoding="utf-8"?> <TabHost xmlns:android="http://schemas.and

我已经看到了,但是我想知道如何在XML文件中实现这一点。。我的目标是在顶部有一组选项卡,使用所有可用的屏幕宽度。我现在不知道该怎么做。设置tabhost的布局宽度以填充父对象并不能达到这个目的。

当我使用Tab时,我通常只是通过将android可见性设置为Goe来隐藏tabwidget标记

并添加按钮作为选项卡按钮,如

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/tabhost" 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="0dip"
            android:layout_weight="1.0"/>
        <FrameLayout android:layout_width="fill_parent" 
            android:layout_height="wrap_content">
            <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" 
                android:layout_height="wrap_content"
                android:visibility="gone"/>
            <LinearLayout android:layout_width="fill_parent" 
                android:layout_height="64dip">
                <Button android:layout_height="fill_parent" android:layout_width="0dip" 
                    android:layout_weight="1.0"
                    android:background="@drawable/ic_tab_artists" 
                    android:id="@+id/artist_id" android:onClick="tabHandler"/>
                <Button android:layout_height="fill_parent" android:layout_width="0dip" 
                    android:layout_weight="1.0"
                    android:background="@drawable/ic_tab_artists" 
                    android:id="@+id/album_id" android:onClick="tabHandler"/>
                <Button android:layout_height="fill_parent" android:layout_width="0dip"     
                    android:layout_weight="1.0"
                    android:background="@drawable/ic_tab_artists" 
                    android:id="@+id/song_id" android:onClick="tabHandler"/>
            </LinearLayout> 
        </FrameLayout>
    </LinearLayout>
</TabHost>

当我使用标签时,我通常只是通过将android可见性设置为Goe来隐藏tabwidget标签

并添加按钮作为选项卡按钮,如

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/tabhost" 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="0dip"
            android:layout_weight="1.0"/>
        <FrameLayout android:layout_width="fill_parent" 
            android:layout_height="wrap_content">
            <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" 
                android:layout_height="wrap_content"
                android:visibility="gone"/>
            <LinearLayout android:layout_width="fill_parent" 
                android:layout_height="64dip">
                <Button android:layout_height="fill_parent" android:layout_width="0dip" 
                    android:layout_weight="1.0"
                    android:background="@drawable/ic_tab_artists" 
                    android:id="@+id/artist_id" android:onClick="tabHandler"/>
                <Button android:layout_height="fill_parent" android:layout_width="0dip" 
                    android:layout_weight="1.0"
                    android:background="@drawable/ic_tab_artists" 
                    android:id="@+id/album_id" android:onClick="tabHandler"/>
                <Button android:layout_height="fill_parent" android:layout_width="0dip"     
                    android:layout_weight="1.0"
                    android:background="@drawable/ic_tab_artists" 
                    android:id="@+id/song_id" android:onClick="tabHandler"/>
            </LinearLayout> 
        </FrameLayout>
    </LinearLayout>
</TabHost>

我添加了一个水平滚动条并设置了
android:fillViewport=“true”
我添加了一个水平滚动条并设置了
android:fillViewport=“true”