0

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.

CandleCoder
  • 1,387
  • 4
  • 21
  • 45
Isj
  • 2,020
  • 1
  • 14
  • 20

1 Answers1

0

You can try this

model_btn.setCompoundDrawablesWithIntrinsicBounds( R.drawable.id, 0, 0, 0);
CandleCoder
  • 1,387
  • 4
  • 21
  • 45
  • In this all the parameters need to be in, so I cant pass sd.getDrawable(), rather I have to pass the R.drawable.id of the drawable and then I cant resize the drawable in code. – Isj Feb 22 '16 at 06:57
  • This way I wiont be able to resize the drawable through code – Isj Feb 22 '16 at 07:07
  • go to http://stackoverflow.com/questions/8198561/calculate-image-size-when-using-setcompounddrawables-for-edittext or http://stackoverflow.com/questions/14430893/resize-images-and-setcompounddrawableswithintrinsicbounds – CandleCoder Feb 22 '16 at 07:11