setCompoundDrawables使用

来源:互联网 发布:淘宝网天猫女西装外套 编辑:程序博客网 时间:2024/05/21 23:34
写界面时有时候会用到drawableRight、drawableLeft等显示给TextView添加Drawable,可能会随着项目逻辑流程等进行需要隐藏这些Drawable,setCompoundDrawables的使用恰好很完美的解决了这一问题。
setCompoundDrawables(Drawable left, Drawable top, Drawable right, Drawable bottom)

函数解读:

可以在上、下、左、右设置图标,如果不想在某个地方显示,则设置为null。但是Drawable必须已经setBounds(Rect)。意思是你要添加的资源必须已经设置过初始位置、宽和高等信息

0 0