Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set tint color for setCompoundDrawablesWithIntrinsicBounds?

I have a tab layout in which i am setting the text and vector image like this:

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

How can i change the tint color for the drawable vector image?

like image 806
bhaskar Avatar asked Oct 24 '25 04:10

bhaskar


1 Answers

Try like this:

Drawable drawables[] = textView.getCompoundDrawables();
drawables[0].setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN));
like image 127
Yuriy Shemetov Avatar answered Oct 25 '25 18:10

Yuriy Shemetov