关于 TextView.setCompoundDrawables() 无效

来源:互联网 发布:工资单打印软件 编辑:程序博客网 时间:2024/05/01 06:36

Added in API level 1

Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text. Use null if you do not want a Drawable there. The Drawables must already have had setBounds(Rect) called.

Calling this method will overwrite any Drawables previously set using setCompoundDrawablesRelative(Drawable, Drawable, Drawable, Drawable) or related methods.

Related XML Attributes
android:drawableLeft
android:drawableTop
android:drawableRight
android:drawableBottom

一定要记得先调用 setBounds(Rect),否则 setCompoundDrawables() 会不起作用。忘记调用 setBounds(Rect) 时没有错误提示,不易查找问题所在。

0 0