I have the following TextView
:
<TextView
android:drawableLeft="@drawable/loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Updating Rates" />
And the result is this:
How do I make the loading circle drawable constrain proportionally so its height matches the height of the text?
Also, if possible, I would like to add some spacing between the text and the image.
To make the loading
smaller just make the images smaller.
Or use RelativeLayout
and put the loading in an ImageView
and scale it.
Or you can add padding between the drawables and the text using android:drawablePadding
(or setCompoundDrawablePadding()
):
android:drawablePadding="3dp"
I think I found the solution, but a bit late
Drawable drawable = getResources().getDrawable(R.drawable.s_vit);
drawable.setBounds(0, 0, (int)(drawable.getIntrinsicWidth()*0.5),(int)(drawable.getIntrinsicHeight()*0.5));
ScaleDrawable sd = new ScaleDrawable(drawable, 0, scaleWidth, scaleHeight);
Button btn = findViewbyId(R.id.yourbtnID);
btn.setCompoundDrawables(sd.getDrawable(), null, null, null);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With