How to set the android:drawableEnd
of TextView
from the java code?
the setCompoundDrawablesRelativeWithIntrinsicBounds(int,int,int,int)
can be used on left, right, top and bottom only. how to set drawableEnd
?
Use 0 or null if you do not want a Drawable there. textView. setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); The Drawables' bounds will be set to their intrinsic bounds. Calling this method will overwrite any Drawables previously set using {@link #setCompoundDrawablesRelative} or related methods.
How to set Background of button in Android programmatically? setBackgroundResource() method is used to change the button background programmatically. setBackgroundResource(int id) accepts id of drawable resource and applies the background to the button.
To set drawableend programatically,Use below code. Worked for me.
rowTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, R.drawable.ic_call_black_24dp, 0);
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