setCompundDrawables() not working in android M

264 Views Asked by At

This is the code I am using to resize the drawable:

Drawable drawable = model_btn.getCompoundDrawables()[0];


        drawable.setBounds(0, 0, (int) (height * 0.065),
                (int) (height * 0.065));


        ScaleDrawable sd = new ScaleDrawable(drawable, 0, 50, 50);

If I use

model_btn.setCompoundDrawables(sd.getDrawable(), null, null, null);

The drawable left is not showing.

If I use:

  model_btn.setCompoundDrawablesWithIntrinsicBounds(sd.getDrawable(), null, null, null);

It shows the drawable left but without resizing.

Your suggestions are appreciated.

1

There are 1 best solutions below

3
CandleCoder On

You can try this

model_btn.setCompoundDrawablesWithIntrinsicBounds( R.drawable.id, 0, 0, 0);