android TabLayout设置tab的时候默认居中,占不满屏幕问题解决

<android.support.design.widget.TabLayout
            app:tabGravity="fill"
            app:tabMode="fixed"
            android:id="@+id/tablayout"
            style="@style/MyTablayoutstyle"
            android:layout_width="match_parent"
            android:layout_height="@dimen/dp_48"/>

如上所示,代码里设置了Tablayout,显示的结果为
在这里插入图片描述
2个tab不能平分,然后我们在加入一个
app:tabMaxWidth=“0dp”

再次运行得到的结果为
在这里插入图片描述平分了2个tab,因此2个tab想要平分空间必须同时设置
app:tabMaxWidth=“0dp”
app:tabGravity=“fill”
app:tabMode=“fixed”

猜你喜欢

转载自blog.csdn.net/cjy_win/article/details/88841057
今日推荐