gpt4 book ai didi

android - 如何在 TabLayout 中设置图标大小?

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:53:59 25 4
gpt4 key购买 nike

这是我的代码:

private TabLayout tabLayout;
private int[] tabIcons = {
R.mipmap.ic_compass,
R.mipmap.ic_place,
R.mipmap.ic_passport,
R.mipmap.ic_setting
};


...
tabLayout.getTabAt(0).setIcon(tabIcons[0]);
tabLayout.getTabAt(1).setIcon(tabIcons[1]);
tabLayout.getTabAt(2).setIcon(tabIcons[2]);
tabLayout.getTabAt(3).setIcon(tabIcons[3]);

图标的大小根据图片大小而定。我该如何调整它的大小?

最佳答案

设置图标内边距

    for (int i = 0; i < tablayout.getTabWidget().getChildCount(); i++)
{
tablayout.getTabWidget().getChildAt(i).setPadding(10,10,10,10);
}

关于android - 如何在 TabLayout 中设置图标大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34669455/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com