如何在Android中的TabLayout中将选项卡标题对齐到左侧

Nam*_*man 8 android android-layout android-tablayout

我似乎无法在我的TabLayout内部将我的标题标题左对齐.目前,标题是中心的.这就是我想要实现的目标.

这就是我现在所拥有的.我正在使用的代码如下:

<android.support.design.widget.TabLayout
    android:id="@+id/tabs"
    app:tabGravity="fill"
    app:tabMode="fixed"
    app:tabTextColor="@color/white"
    app:tabSelectedTextColor="@color/white"
    app:tabIndicatorColor="@color/white"
    android:background="@color/slate_grey"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
</android.support.design.widget.TabLayout>
Run Code Online (Sandbox Code Playgroud)

Elv*_*eya 18

添加app:tabMode="scrollable"到您的<TabLayout.../>,不要忘记添加xmlns:app="http://schemas.android.com/apk/res-auto".

有关详细信息,请访问https://developer.android.com/reference/android/support/design/widget/TabLayout.html

  • 这应该是正确答案.也可以通过代码来实现,`tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE)` (3认同)

kop*_*kao 5

只需将 TabLayout 宽度设置为 wrap_content。完毕。