How to set
android:drawableTop="@drawable/your_drawable_selector"
through java for a RadioButton in android?
How to set
android:drawableTop="@drawable/your_drawable_selector"
through java for a RadioButton in android?
You can use setCompoundDrawablesWithIntrinsicBounds, since RadioButton is a subclass of TextView
. E.g.
radioButton.setCompoundDrawablesWithIntrinsicBounds (0, R.drawable.your_drawable_selector, 0, 0)
.
If you have a Bitmap you can use
Drawable drawable = new BitmapDrawable(getResources(), yourBitmap);
radioButton.setCompoundDrawablesWithIntrinsicBounds(null, drawable, null, null);
From the documentation
Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text. Use 0 if you do not want a Drawable there. The Drawables' bounds will be set to their intrinsic bounds.