Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Button drawableLeft - how to hardcode it (no xml)

How can I add a "drawable left" icon to a button object?

I mean something like this:

Button button = new Button();
button.setDrawableLeft(R.drawable...);
like image 459
Kangee Avatar asked Nov 03 '10 22:11

Kangee


1 Answers

Use Button.setCompoundDrawablesWithIntrinsicBounds(..) which relates to android:drawableLeft attribute.

like image 109
Peter Knego Avatar answered Sep 27 '22 17:09

Peter Knego