TabLayout中每页固定数量的标签

TabLayout中每页固定数量的标签

本文介绍了TabLayout中每页固定数量的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将可滚动的TabLayout与ViewPager一起使用.
我想确保在任何给定时间每页显示7个选项卡.即使选项卡的总数为10,我也希望每页有7个,然后滚动以显示其他3个.
我找不到控制显示的选项卡数量的属性.

I am using scrollable TabLayout with a ViewPager.
I want to make sure that at any given time I have 7 tabs displayed per page. Even if the total number of tabs is 10, I want to have 7 per page, and scroll to expose the other 3.
I can't find a property to control the number of tabs displayed.

推荐答案

最终,对我有用的是计算每个单元格的所需大小,以获得每页所需的选项卡总数,并在android.support.design.widget.TabLayout

Eventually what worked for me was to calculate the desired size of each cell to get the total amount of tabs that I needed per page and set app:tabMaxWidth inside android.support.design.widget.TabLayout

这篇关于TabLayout中每页固定数量的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 04:28