我想将 tablayout 的指示器从底部更改为顶部。
我的代码
activity_tab.xml
<android.support.design.widget.AppBarLayout
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:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabIndicatorColor="#000000"
app:tabMode="scrollable"
/>
</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" />
我想要这个结果。
怎么做
谢谢你问我,抱歉英语不好。
最佳答案
不要使用 scale = -1 之类的东西。
从 XML 您可以使用 app:tabIndicatorGravity="top"
从代码中您可以使用 setSelectedTabIndicatorGravity(INDICATOR_GRAVITY_TOP)
关于android - 如何将tablayout的指示器从底部更改为顶部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33810156/