Ich beziehe mich auf eine große demo here in Bezug auf Material Design. Es hat Registerkarten, aber wenn ich zu viele hinzufügen, werden die Tab-Elemente zerquetscht (siehe Screenshot). Wie kann ich es horizontal scrollen lassen?Wie aktiviert man das horizontale Scrollen im Tab wie Google Play?
ich unten glauben, ist das Layout ich die Änderung vornehmen sollte, aber ich gekämmt die Dokumentation und kann nicht scheinen, um es zu bekommen, pls helfen!
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways" />
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/ic_done" />
</android.support.design.widget.CoordinatorLayout>
Versuchen Sie Ihre 'TabLayout' setzen in' HorizontalScrollingView'? –
hey @ N1to das hat funktioniert! Pls gehen als Antwort und ich werde akzeptieren. Ich habe gerade 'TabLayout' mit' 'eingepackt. Die einzige Sache ist, wenn ich zu einem Tab auf dem Bildschirm wische, es nicht auf diesen Tab konzentriert. –
TruMan1
Tu das nicht, TabLayout selbst ist schon ein HorizontalScrollview. Sie sollten das TabLayout in MODE_SCROLLABLE setzen (es ist in den Dokumenten) – BladeCoder