TextView的setCompoundDrawables不显示问题解决

 
 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。如果不设置则无法显示。

安卓开发交流群:安卓帮595856941

猜你喜欢

转载自blog.csdn.net/q9104422999/article/details/84099793