开发者

Make ImageView disappear after setting it

I cannot get rid of the ImageView after setting it (img.setImageResource(R.drawable.xxx);)! I tried everything:

img.setVisibility(View.INVISIBLE)

and

img.setVisibility(View.G开发者_Python百科ONE)

and

LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
params.width=0;
params.height=0;

Also searched a lot about this. Can anyone help?


This should work, as long as you execute it in a GUI thread (not in a Thread, not in background AsyncTask) and you NOT do something like "make invisible; do longrunning calculations; make visible again" in one single piece of code.


I'm not sure why that isn't working, but as an extreme solution you can try removing the View entirely. Call removeView( img ); on the ViewGroup (the layout) that directly contains the ImageView.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜