How to clear ImageView correctly?

泄露秘密 提交于 2019-12-03 02:18:36
imgview.setImageResource(0);

or

imgview.setImageDrawable(null);

no you need to unbindDrawables, you can do it by setting iview.setImageDrawable(null);

Dhiraj Singh

You can use frequently it works:

imageView.setImageResource(0);
viewToUse.setImageResource(android.R.color.transparent);
  • I think using setImageResource with a color identifier will give you crashing issues on Android 2.2.1, make sure to test it.

if nothing is working for you try setting the background color of view to layout color.if my layout color is white u can do like this:

 edit_countflag.setBackgroundColor(Color.parseColor("#ffffff"));
//then set the image
 edit_countflag.setImageResource(R.drawable.flag_id);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!