我还有一个错误,它会在不同的Android版本上制作不同的标签宽度。在android 4.1.1和android 5.1选项卡宽度服从模式'填充'和tablayout宽度匹配perent。而Android 4.4.4的宽度看起来像wrap_content
。设计库版本23.3.0。如何解决它?TabLayout宽度错误
布局
<?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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:clickable="true"
>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="fixed"
app:tabGravity="fill"
app:tabIndicatorHeight="0dip"
app:tabIndicatorColor="@android:color/transparent"
app:tabBackground="@drawable/tab_request_background"
app:tabTextColor="@color/colorPrimary"
app:tabSelectedTextColor="@color/white"
/>
<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"
/>
</LinearLayout>