0
点赞
收藏
分享

微信扫一扫

TextView的setCompoundDrawables不显示问题解决

余寿 2022-10-22 阅读 152


 TextView可以用过调用setCompoundDrawables设置一张图片出现在上下左右四个地方。代码如下:

Drawable drawable = getResources().getDrawable(R.drawable.delete_circle);

//drawable.setBounds(0, 0, 32, 32);
drawable.setBounds(0, 0, mDeleteIcon.getMinimumWidth(), mDeleteIcon.getMinimumHeight());

//设置需要现实的位置 , 不需要显示的 直接填null 即可
textView.setCompoundDrawables(drawable, null, null, null);

注意 : 到这个Drawables必须已经调用过了setBounds。如果不设置则无法显示。



举报

相关推荐

0 条评论