Yes use setCompoundDrawablesWithIntrinsicBounds
and determine the value for the first parameter, then 0 for all the others.
The code should look something like this:
Button b = findViewById(R.id.myButton);
b.setCompoundDrawablesWithIntrinsicBounds(R.drawable.myDrawable, 0, 0, 0);
If your drawable was also created in the code, you need to use another setCompoundDrawablesWithIntrinsicBounds method , which takes 4 pictures and passes null for all but the left.
source
share