我关注了this tutorial .我做了简单的更改,显示 TabLayout在屏幕底部。
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v4.view.ViewPager
android:id="@+id/viewpager_landing"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
android:background="@android:color/white" />
<android.support.design.widget.TabLayout
android:id="@+id/sliding_tabs_landing"
style="@style/MyCustomTabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="fixed" />
</LinearLayout>
问题:-
TabIndicator
显示在屏幕底部效果很好,现在我想在选项卡顶部而不是底部显示 TabIndicator
。
使用自定义布局,我们可以按照教程中的说明进行操作,但是是否有任何 xml 属性会在顶部显示 TabIndicator
?
最佳答案
以 XML 格式将此行添加到您的 TabLayout
app:tabIndicatorGravity="top"
关于java - 如何在选项卡顶部显示选项卡指示器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32633863/