gpt4 book ai didi

android - 如何为 setCompoundDrawablesWithIntrinsicBounds 设置色调颜色?

转载 作者:搜寻专家 更新时间:2023-11-01 07:46:30 26 4
gpt4 key购买 nike

我有一个选项卡布局,我在其中设置文本和矢量图像,如下所示:

    TextView tab2 = (TextView) LayoutInflater.from(this).inflate(R.layout.custom_tab, null);
tab2.setText("OFFER");
tab2.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_offer, 0, 0);
tabLayout.addTab(tabLayout.newTab().setCustomView(tab2));

如何更改可绘制矢量图像的色调?

最佳答案

像这样尝试:

Drawable drawables[] = textView.getCompoundDrawables();
drawables[0].setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN));

关于android - 如何为 setCompoundDrawablesWithIntrinsicBounds 设置色调颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43087035/

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