如何将标签布局的指示器从底部更改为顶部? [英] How to change indicator of tablayout to top from bottom?
本文介绍了如何将标签布局的指示器从底部更改为顶部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将标签布局的指示从底部更改为顶部.
I want to change indicator of tablayout from bottom to top.
我的代码
activity_tab.xml
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之类的东西.
Don't use scale = -1 and things like that.
在XML中,您可以使用app:tabIndicatorGravity="top"
From XML you can use app:tabIndicatorGravity="top"
通过代码,您可以使用setSelectedTabIndicatorGravity(INDICATOR_GRAVITY_TOP)
From code you can use setSelectedTabIndicatorGravity(INDICATOR_GRAVITY_TOP)
这篇关于如何将标签布局的指示器从底部更改为顶部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文