RelativeLayout relativeLayout = findViewById(R.id.my_relative_layout); int visibility = relativeLayout.getVisibility(); if (visibility == View.VISIBLE) { // Do something if the layout is visible. } else if (visibility == View.INVISIBLE) { // Do something if the layout is invisible. } else if (visibility == View.GONE) { // Do something if the layout is gone. }
RelativeLayout relativeLayout = findViewById(R.id.my_relative_layout); relativeLayout.setVisibility(View.GONE);The `android.widget.RelativeLayout` class is part of the `android.widget` package library.