如何在Android中的TabLayout中使标签标题向左对齐

如何在Android中的TabLayout中使标签标题向左对齐

本文介绍了如何在Android中的TabLayout中使标签标题向左对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法在TabLayout中将标签标题向左对齐.目前,标题居中.这是我想要的.

I can't seem to align my tab titles to the left, inside my TabLayout. At the moment, the titles are centered. Here is what I want to achieve.

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

And this is what I have at the moment.The code I'm using is as follows:

<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>

推荐答案

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

add app:tabMode="scrollable" to your <TabLayout.../> and don't forget to add xmlns:app="http://schemas.android.com/apk/res-auto" too.

有关更多信息,请查看 https://developer.android .com/reference/android/support/design/widget/TabLayout.html

For more info check out https://developer.android.com/reference/android/support/design/widget/TabLayout.html

这篇关于如何在Android中的TabLayout中使标签标题向左对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 06:27