Android how to set a transparent image resource of a view? or Remove the image?

只愿长相守 提交于 2019-12-12 20:04:39

问题


((ImageView) v.findViewById(R.id.imageViewHeart1)).setImageResource(R.drawable.heart);

I d like to remove my graphicss from my Image Resource so:

((ImageView) v.findViewById(R.id.imageViewHeart1)).setImageResource(null);

or something, how can I do this?


回答1:


If you remove image then used

((ImageView) v.findViewById(R.id.imageViewHeart1)).setImageResource(0);




回答2:


Use ImageView.setImageDrawable(null); or simply View.setVisibility(View.INVISIBLE);




回答3:


Try add transparent png with 1px width and 1px height.



来源:https://stackoverflow.com/questions/6015280/android-how-to-set-a-transparent-image-resource-of-a-view-or-remove-the-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!