how to setImage to null in android when the xml has src not null?

后端 未结 4 413
孤街浪徒
孤街浪徒 2021-01-24 19:57

I have this xml



        
相关标签:
4条回答
  • 2021-01-24 20:15

    if u want to null imageview then u have to call imageButton.setImageResource(0); BackgroundResource only null that background of image dude

    0 讨论(0)
  • 2021-01-24 20:16

    you can use imageButton.setImageResource(0)

    0 讨论(0)
  • 2021-01-24 20:33

    The background (backgroundresource) and foreground (src) image are two different things, thus the one does not influence the other.

    Remove the foreground image using:

    imageButton.setImageDrawable(null);
    
    0 讨论(0)
  • 2021-01-24 20:36

    Try this..

    Your setting setBackgroundResource that's for android:background="@drawable/icon_on" not for android:src="@drawable/icon_on" background and src both are different use

    imageButton.setImageResource(0);
    

    EDIT

    imageButton.setImageDrawable(null);
    
    0 讨论(0)
提交回复
热议问题