-4

I have this xml

<ImageView
    android:id="@+id/ImgOn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:src="@drawable/icon_on" />

I want to remove this image sometimes via code. I've seen many posts like this, but in my case imageButton.setImageResource(0); leaves the default image which appears in my xml layout.

How would you remove it programmatically? I heard transparent color crashes some old devices.

Community
  • 1
  • 1
Elad Benda2
  • 13,852
  • 29
  • 82
  • 157

1 Answers1

1

you can use imageView.setImageDrawable(null);

gandharva
  • 691
  • 5
  • 16