gpt4 book ai didi

android - TabLayout tabItem tabGravity center 不工作

转载 作者:行者123 更新时间:2023-11-30 00:23:00 29 4
gpt4 key购买 nike

它在超过 5 个标签时工作正常,但当 3 个标签看起来不太好时。
这是我的 TabLayout XML 代码:

 <android.support.design.widget.TabLayout
android:gravity="center"
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/search_bar"
android:fillViewport="false"
app:tabGravity="center"
app:tabIndicatorColor="@color/ThemeColor"
app:tabIndicatorHeight="6dp"
app:tabMode="scrollable"
android:paddingBottom="2dp"
android:background="@drawable/bottom_dotted_border"
app:tabSelectedTextColor="@color/ThemeColor"
app:tabTextAppearance="@style/TabLayoutTextStyle"
app:tabTextColor="@color/White" />

problamatic tab desire tab

最佳答案

只是改变这个 app:tabMode="scrollable" app:tabMode="fixed" < strong>在你的标签布局中

1. app:tabMode="fixed : the tabs are fixed in your tab layout (its not good for when your tabs have long tabtitles)

2. tabMode:scrollable - you can scroll your tabs horizontally when your tabs have long tabtitles

示例代码

<android.support.design.widget.TabLayout
android:gravity="center"
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/search_bar"
android:fillViewport="false"
app:tabGravity="fill"
app:tabMode="fixed"
app:tabIndicatorColor="@color/ThemeColor"
app:tabIndicatorHeight="6dp"
android:paddingBottom="2dp"
android:background="@drawable/bottom_dotted_border"
app:tabSelectedTextColor="@color/ThemeColor"
app:tabTextAppearance="@style/TabLayoutTextStyle"
app:tabTextColor="@color/White" />

关于android - TabLayout tabItem tabGravity center 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45932120/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com