How to set property "android:drawableTop
" of a button at runtime
Use
button.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);
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.
If you use
button.setCompoundDrawables(left, top, right, bottom);
Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text. Use null if you do not want a Drawable there. The Drawables must already have had setBounds(Rect) called.
Drawable top = getResources().getDrawable(R.drawable.image); button.setCompoundDrawablesWithIntrinsicBounds(null, top , 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