I’m new on Android development, so I’m developing an simple application that hides a textview pressing some button, so in the java code in the method for the OnClick event for the button I set the textview as invisible, I used:
textView.setVisibility(1);
because 1 is the value for “invisible” described in the android reference, but it does not work, so after I used
textView.setVisibility(View.INVISIBLE);
and it works, so When is the “1” value used? and Why is View.INVISIBLE = 4 instead of 1 as the android reference says?
In the android reference I can see that the value Invisible for attribute android:visibility is defined as 1
This is a good question, I checked the Android source code (frameworks/base/core/java/android/view/View.java)
Here is the content of VISIBILITY_FLAGS:
The value of the array elements are actually the value shown in Android Reference
So even if you use the android:invisible in the manifest file, Android framework will finally call setVisibility(…) with the value 4.