Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set android textView drawableEnd programmatically

Tags:

android

layout

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?

like image 304
null pointer Avatar asked Oct 15 '13 14:10

null pointer


People also ask

How to remove drawable from TextView programmatically Android?

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 can change button background drawable in android programmatically?

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.


1 Answers

To set drawableend programatically,Use below code. Worked for me.

   rowTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, R.drawable.ic_call_black_24dp, 0);
like image 168
Priyanka Thakkar Avatar answered Sep 19 '22 08:09

Priyanka Thakkar