7

このアプリケーションを実装しようとしています。現在、タブをデザインしていますが、7つ以上のタブがあるため、混雑しすぎているように見えます。タブウィジェットが水平方向にスクロールできるように設計するにはどうすればよいですか。市場に出回っているいくつかのアプリでこのデザインを見たことがありますが、これをアプリに実装する方法がわかりません。

私が見たあるアプリには、それ自体がスクロールする水平スクロールビューがあり、特定の画像/ボタンを押すと、いくつかのコンテンツが表示されます。それは私が推測するタブではなかったようです。

それで、誰かがこれについての考えを持っていますか?

4

5 に答える 5

15

AndroidデザインライブラリのTabLayout

<android.support.design.widget.TabLayout
    android:id="@+id/categories"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:tabMode="scrollable" />
于 2016-01-14T13:02:29.613 に答える
4

これは、Horizo​​ntalScrollViewを使用した非常に良い例です。 http://java.dzone.com/articles/scrolling-tabs-android

于 2012-03-14T14:36:47.237 に答える
2

JakeWhartonのViewPagerアプリをチェックしてください。それはまさにあなたが必要とするものです。これはライブラリプロジェクトであるため、プロジェクトに含める必要があります。

JakeWharton / Android-ViewPagerIndicator

于 2012-03-14T14:36:00.660 に答える
2
<HorizontalScrollView 
    android:id="@+id/vTabs" 
    android:scrollbars="none" 
    android:layout_width="fill_parent" 
    android:layout_alignParentBottom="true"
    android:layout_height="wrap_content">
    <LinearLayout 
        android:orientation="horizontal" 
        android:background="@color/main_color_gray_dk" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content">
        <Button 
            android:enabled="false" 
            android:id="@+id/tab1" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:text="@string/popular" />
        <View 
            android:id="@id/view1" 
            android:layout_width="@dimen/pad_1dp" 
            android:layout_height="fill_parent" />
        <Button 
            android:id="@id/tab2" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:text="@string/newest" />
        <View 
            android:id="@id/view1" 
            android:layout_width="@dimen/pad_1dp" 
            android:layout_height="fill_parent"  />
        <Button 
            android:id="@id/tab3" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:text="@string/distance" />
        <View 
            android:id="@id/view1" 
            android:layout_width="@dimen/pad_1dp" 
            android:layout_height="fill_parent"  />
        <Button 
            android:id="@+id/tab4" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:text="@string/minimum"  />
    </LinearLayout>
</HorizontalScrollView>

テキストを好みに合わせて変更します。relatveLayoutに配置し、alignToParentBottom="true"これがお役に立てば幸いです

于 2016-01-31T13:43:12.733 に答える
0

このリンクを確認してください:https ://dzone.com/articles/scrolling-tabs-android

TabWidgetをHorizo​​ntalScrollViewでラップすると、タブセットが画面の幅を超えて拡張できるようになり、ユーザーは必要に応じてタブを左右にドラッグできます。

<?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">    <HorizontalScrollView android:layout_width="fill_parent"                          android:layout_height="wrap_content"                          android:fillViewport="true"                          android:scrollbars="none">      <TabWidget android:id="@android:id/tabs"                 android:layout_width="fill_parent"                 android:layout_height="wrap_content"/>    </HorizontalScrollView>    <FrameLayout android:id="@android:id/tabcontent"                 android:layout_width="fill_parent"                 android:layout_height="fill_parent" />  </LinearLayout></TabHost>
于 2015-10-24T00:08:26.977 に答える