Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setCompoundDrawablesWithIntrinsicBounds vs. android:drawableRight

Tags:

android

What is the difference between setting a drawable via xml like

android:drawableRight="@drawable/arrow_right_normal"

and setting a drawable via code like

bt.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.arrow_right_normal);

Because in the first case everything works like expected (Buttontext is center horizantal and the icon is in the middle of the right side). And in the second case the icon is at the bottom/middle of the Button and the Text is at the top left side.

like image 500
user2082415 Avatar asked Apr 25 '14 10:04

user2082415


1 Answers

right is the third parameter. The last one is bottom

bt.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.arrow_right_normal,0);

Here the documentation

like image 153
Blackbelt Avatar answered Oct 23 '22 09:10

Blackbelt