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) 时没有错误提示,不易查找问题所在。
本文介绍了如何使用setCompoundDrawables()方法来设置文本周围的图片,并强调了调用setBounds(Rect)的重要性,否则setCompoundDrawables()将不会生效。
1381

被折叠的 条评论
为什么被折叠?



