Java 如何在选项卡顶部显示选项卡指示器
我跟着。我做了一些简单的改变,显示在屏幕底部 activity_main.xmlJava 如何在选项卡顶部显示选项卡指示器,java,android,android-support-library,androiddesignsupport,Java,Android,Android Support Library,Androiddesignsupport,我跟着。我做了一些简单的改变,显示在屏幕底部 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_
<?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
?这对我很有用:
LinearLayout tabs = ((LinearLayout) tabLayout.getChildAt(0));
for (int position = 0; position < tabs.getChildCount(); position++) {
LinearLayout item = ((LinearLayout) tabs.getChildAt(position));
item.setRotationX(180);
}
LinearLayout选项卡=((LinearLayout)tabLayout.getChildAt(0));
对于(int position=0;position
将此行添加到XML格式的表格布局中
app:tabIndicatorGravity="top"
把你的xml代码放进去。thx@Fakher我已经发了xml@Nilesh你做到了吗?我还想在顶部显示制表符。@NiteshKhatri否默认情况下不是,因为现在我已经为此定制了布局,请参考