ImageView myImageView = findViewById(R.id.my_imageview); int visibilityState = myImageView.getVisibility(); if (visibilityState == View.VISIBLE) { // Do something if ImageView is visible } else { // Do something else if ImageView is not visible }
import android.view.View; ... ImageView myImageView = findViewById(R.id.my_imageview); myImageView.setVisibility(View.INVISIBLE);This example shows how to use the setVisibility method to change the visibility state of an ImageView. The code sets the ImageView's visibility state to invisible using the View.INVISIBLE constant. The package library for the android.widget.ImageView class is included within the Android SDK, and can be accessed by importing the android.widget package.