I'm using a Button
<Button
android:id="@+id/zoom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/trans"
android:drawableLeft="@drawable/left_img"
android:fontFamily="arial"
android:text="My Name is "
android:textSize="50sp" />
and changing its text color with :
zoom.setTextColor(Color.parseColor("voilet"));
but not able to understand how to change its image??
Try this:
Reference
just follow this code i hope it's really helpful for you..
I recomend that instead of using a button you use an Imageview and add an onclick listener to it. That way you can just do
Imageview.setbitmap(bitmap)
and create a bitmap from one of your drawablesThe safest way to set the left drawable without changing the values of the other drawables (top, right, and bottom):
To do this, you can use the
setCompoundDrawables(...);
method. Be aware that comes with TextView, not Button.
This is how to use it:
Taken from: How to programmatically set drawableLeft on Android button?