ViewPagerAdapter工具栏可水平滚动

时间:2020-01-27 09:05:22

标签: android xml android-layout

我有很多的标签工具栏,但是当有太多的标签,文本内部分裂,所有的标签都是我的屏幕上。 我希望工具栏可滚动,但我自己不能做。

这是我的布局:

<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <com.google.android.material.appbar.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay"
        >

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:scrollbars="horizontal"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay"
            app:layout_scrollFlags="scroll|enterAlways"

            />
    </com.google.android.material.appbar.AppBarLayout>

    <include layout="@layout/content_main" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>

我尝试用NestedScrollView替换appbarlayout,但不起作用。 谢谢您的帮助。


enter image description here

您可以看到选项卡的名称被拆分,因为选项卡太多。我希望将工具栏的大小调整为选项卡,并且无法在tabLayout中水平滚动。

0 个答案:

没有答案