TextView的setCompoundDrawables不显示问题解决
发布时间:2022-10-30 08:04:19 206 相关标签:
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。如果不设置则无法显示。
文章来源: https://blog.51cto.com/u_11288266/5785552
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报