0

私はアンドロイドが初めてで、Tabspecが同じサイズでなければならないTabWidgetを1つ表示したい...内部に何があるかは関係ありません...さらに、8つのタブを表示したいので、Horizo​​ntallScrollViewを1つ追加しました私の活動は、3つだけではありません...

8 つのアクティビティを同じタブ サイズにするには、xml に何を追加する必要があるか、誰でも知っていますか?

<?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"
        android:padding="5dp">
        <HorizontalScrollView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" 
                android:scrollbarAlwaysDrawHorizontalTrack="true"
                android:scrollbars="horizontal"/>
        </HorizontalScrollView>
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="5dp" />
    </LinearLayout>

</TabHost>

ありがとうございました

4

1 に答える 1

0

通常、次のようなタブを作成します。

tabHost.addTab(tabHost.newTabSpec("tag")
                .setIndicator("tab title", icon))
                .setContent(this));

これにより、TabHostは、 TabSpecをホストするために選択したビューを作成します。ただし、ビューをパラメーターとして受け取る setIndicatorのオーバーロードがあります。したがって、固定幅のビューを作成し、このオーバーロードのsetIndicatorTabSpecsに使用できます。

于 2011-03-22T23:54:56.210 に答える