繁体   English   中英

如何设置setCompoundDrawablesWithIntrinsicBounds的颜色?

[英]How to set tint color for setCompoundDrawablesWithIntrinsicBounds?

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

    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));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM