为什么TextView的setCompoundDrawables设置后图片不显示?
- 内容介绍
- 文章标签
- 相关推荐
本文共计123个文字,预计阅读时间需要1分钟。
TextView可以调用setCompoundDrawables设置一张图片出现在上下左右四个方位。代码如下:
Drawable drawable=getResources().getDrawable(R.drawable.delete_circle);drawable.setBounds(0, 0, 32, 32);setCompoundDrawables(drawable, null, null, null);
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。如果不设置则无法显示。
本文共计123个文字,预计阅读时间需要1分钟。
TextView可以调用setCompoundDrawables设置一张图片出现在上下左右四个方位。代码如下:
Drawable drawable=getResources().getDrawable(R.drawable.delete_circle);drawable.setBounds(0, 0, 32, 32);setCompoundDrawables(drawable, null, null, null);
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。如果不设置则无法显示。

