TextView myTextView = findViewById(R.id.my_text_view); int visibility = myTextView.getVisibility(); if (visibility == View.VISIBLE) { // Do something if text view is visible } else { // Do something if text view is not visible }
TextView myTextView = findViewById(R.id.my_text_view); myTextView.setVisibility(View.GONE);In this example, we set the visibility of a TextView object to be "GONE" which means that the text view is no longer visible and does not take up any space in the layout. Package library: android.widget