What is the difference between setting drawable via xml, for example
android:drawableRight="@drawable/arrow_right_normal"
and setting code using code, for example
bt.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.arrow_right_normal);
Because in the first case, everything works as expected (Buttontext is central horizontal and the icon is in the middle of the right side). And in the second case, the icon is in the lower part / middle of the button, and the text is in the upper left part.
source
share