I need put text and image into button and need do it dynamically. I know how do it in xml code but I can`t transfer it to java code.
Asked
Active
Viewed 423 times
2 Answers
1
Try this,
Button b=new Button(this);
b.setCompoundDrawablePadding(10);
b.setCompoundDrawablesWithIntrinsicBounds(R.drawable.icon, 0, 0, 0);
Andro Selva
- 53,136
- 52
- 190
- 238
-
It`s working thanks :D – marusinm Aug 21 '13 at 07:01
0
try this code:
button.setCompoundDrawables(Drawable left,Drawable top,Drawable right,Drawable bottom);
shiju B
- 1,690
- 10
- 23