Daniel Kvist Daniel Kvist - 8 months ago 33
Java Question

The proper way of hiding and showing Android Views?

I'm creating an app and I wonder what the proper way to hide and show a View is? I've seen many saying that changing the alpha value for the View will hide it, but will it stop reacting to clicks then?
Because, in reality, something that is transparent can still be touched, like glass. These are just thoughts, so correct me if I'm wrong.

Answer Source

To show/hide a View programmatically you can use setVisibility(int visibility).

The visibility parameter can be:

  • View.VISIBLE - shows the View.
  • View.GONE - hides the View and recalculates the layout.
  • View.INVISIBLE - hides the View, but still leaves/occupies its space in the layout.