当前位置:主页 > >

解决Android TabLayout 在宽屏幕上tab不能平均分配的问题

时间:2020-08-22 14:00:09 | 栏目: | 点击:

当TabLayout 在宽屏幕的设备上,如平板横屏的时候,tab的宽度超过一定值后,就不在平均分配宽度,而是居中显示。

此时设置

app:tabMode="fixed"

或者

top_table.setTabMode(TabLayout.MODE_FIXED);

不在起作用。

app:tabMaxWidth="0dp"

此值即可解决!

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

补充知识:当TabLayout标签太多时,Tab显示拥挤导致出现省略号显示不全

在布局文件中改控件添加这个属性

app:tabMode="scrollable"

您可能感兴趣的文章:

相关文章