Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set an image's width and height when it's set in drawableLeft

I set an image to a RadioButton's drawableLeft, but it's to big. I want to set the image's height, width and scaleType in order to let it looks ok, just like in an ImageView:

android:layout_width="30dip"
android:layout_height="30dip"
android:scaleType="fitXY"

But i find there are no attributions for image when it's set in drawableLeft.

Is there any ways to solve this.

Is it possible to handle this in XML ?

like image 462
L. Swifter Avatar asked Dec 16 '15 09:12

L. Swifter


1 Answers

I think this should work:

Drawable drawable = context.getResources().getDrawable(id);
drawable.setBounds(0, 0, 30, 30);
radioButton.setCompoundDrawables(drawable, null, null, null);
like image 75
Chintan Soni Avatar answered Oct 08 '22 10:10

Chintan Soni