1

例として見つけたこの単純なレイアウトがあります。

<?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:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <HorizontalScrollView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:fillViewport="true"
            android:scrollbars="none" >

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_gravity="center" />
        </HorizontalScrollView>

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >
        </FrameLayout>
    </LinearLayout>

</TabHost>

コードに 8 つのタブを追加した後、それらが一緒に圧縮されていることがわかります。タブにスクロール可能な機能を追加するにはどうすればよいですか? (コンテンツではなく、タブのみ)

私の電話の1つのアプリにはこれがあり、それもスクロールバーなしで行われます. 基本的に、移動するには、タブを押したままにして左にドラッグし、さらにタブを表示します。これはどのように達成できますか?

4

3 に答える 3

0

これを試しましたか?

<HorizontalScrollView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

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

</HorizontalScrollView>
于 2012-06-04T12:16:08.597 に答える
0

次のように、各タブの最小幅を設定してみてください。

    for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {
        tabHost.getTabWidget().getChildAt(i).setMinimumWidth(200);
    }
于 2012-10-09T09:49:25.133 に答える
0

TabWidget でこれを試してください:

  <HorizontalScrollView 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:fillViewport="true"
    android:scrollbars="none"
    android:layout_alignParentBottom="true">
    <TabWidget
      android:id="@android:id/tabs"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:layout_gravity="center"/>
  </HorizontalScrollView>
于 2012-06-04T12:25:03.790 に答える