setCompoundDrawablesWithIntrinsicBounds vs. android:drawableRight

时间:2014-04-25 10:22:03

标签: android

通过像

这样的xml设置drawable有什么区别
android:drawableRight="@drawable/arrow_right_normal"

并通过代码

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

因为在第一种情况下,一切都像预期的那样工作(Buttontext是中心水平,图标位于右侧中间)。 在第二种情况下,图标位于按钮的底部/中间,文本位于左上角。

1 个答案:

答案 0 :(得分:12)

right是第三个参数。最后一个是底部

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

Here文档