设置drawable的TextView
方法的区别在哪里?文档很模糊。
1) setCompoundDrawables (Drawable left, Drawable top, Drawable right, Drawable bottom)
2) setCompoundDrawablesRelative (Drawable start, Drawable top, Drawable end, Drawable bottom)
3) setCompoundDrawablesWithIntrinsicBounds(Drawable left, Drawable top, Drawable right, Drawable bottom)
4) setCompoundDrawablesRelativeWithIntrinsicBounds(Drawable start, Drawable top, Drawable end, Drawable bottom)
提前致谢。
答案 0 :(得分:33)
setCompoundDrawables
要求您手动调用setBounds(Rect)
上的Drawable
,而setCompoundDrawablesWithIntrinsicBounds
将为您确定Drawable
的界限(种类)喜欢将ImageView
设置为wrap_content
)。
setCompoundDrawablesRelative
与setCompoundDrawables
完全相同,除了使用“left”和“right”之外,它使用“start”和“end”,如果你想支持左边的那么这很有用从右到右和从右到左的本地化(see this blog post for more info)。同样适用于setCompoundDrawablesRelativeWithIntrinsicBounds
和setCompoundDrawablesWithIntrinsicBounds
。