2016-10-28 120 views
1

我需要在TabLayout中减少标签项目的宽度。我花了很多时间寻找解决方案,但看起来并不那么容易。这里是我的布局:如何在android中减少TabLayout中tab项的宽度?

<android.support.v4.view.ViewPager 
    android:id="@+id/pager_chapter" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" /> 

<android.support.design.widget.TabLayout 
    android:id="@+id/tabs_chapter" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    app:tabMode="scrollable" /> 

回答

0

更改的android:layout_width = “match_parent”的android:layout_width = “WRAP_CONTENT” TabLayout视图内

0

这可能工作!

<android.support.design.widget.TabLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     app:tabMaxWidth="0dp" 
     app:tabGravity="fill" 
     app:tabMode="fixed" /> 
+0

谢谢。这会隐藏标签项目。 –