如何为setCompoundDrawablesWithIntrinsicBounds设置色调颜色?

时间:2017-03-29 07:26:21

标签: android image android-vectordrawable tint

我有一个标签布局,我在其中设置文本和矢量图像:

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

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

1 个答案:

答案 0 :(得分:2)

试试这样:

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