jjzjj

android - setCompoundDrawablesWithIntrinsicBounds 与 android :drawableRight

coder 2023-11-23 原文

通过xml设置drawable有什么区别

android:drawableRight="@drawable/arrow_right_normal"

并通过如下代码设置可绘制对象

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

因为在第一种情况下,一切都按预期进行(按钮文本居中水平,图标位于右侧中间)。 在第二种情况下,图标位于按钮的底部/中间,文本位于左上角。

最佳答案

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

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

Here文档

关于android - setCompoundDrawablesWithIntrinsicBounds 与 android :drawableRight,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23290357/

有关android - setCompoundDrawablesWithIntrinsicBounds 与 android :drawableRight的更多相关文章

随机推荐