TabLayout 的不同选项卡宽度 [英] Different tab width for TabLayout

查看:59
本文介绍了TabLayout 的不同选项卡宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 TabLayout &浏览器.我正在尝试更改选项卡的大小,例如 Whatsapp(相机图标).三个Tab的大小相等,但相机的Tab更小.在每次尝试中,我都让标签的大小保持不变(所有标签都相等).谢谢.

I'm using TabLayout & ViewPager. I am trying to change the size of the Tab, like Whatsapp (camera icon). The size of the three Tabs is equal, but the Tab of the camera is smaller. In every attempt I make the size of the Tabs remains the same (equal across all tabs). Thanks.

推荐答案

需要降低对应tab的LinearLayout的权重.

You need to lower the weight of the LinearLayout of the corresponding tab.

LinearLayout layout = ((LinearLayout) ((LinearLayout) tabLayout.getChildAt(0)).getChildAt(YOUR_TAB_NUMBER));
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) layout.getLayoutParams();
layoutParams.weight = YOUR_WEIGHT; // e.g. 0.5f
layout.setLayoutParams(layoutParams);

希望有帮助!

这篇关于TabLayout 的不同选项卡宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆