Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what's the difference of setVisibility(View.INVISIBLE); setVisibility(0);

I met a strange issue, when i set a textview visibility as text.setVisibility(0); I cannot hide this textview. But after i update the code to text.setVisibility(View.INVISIBLE), the textview is hidden...

I have no idea, why this happened....

like image 878
Fiona Avatar asked Dec 26 '11 13:12

Fiona


People also ask

What is the different value of Setvisibility method?

Controls the initial visibility of the view. Must be one of the following constant values. Constant Value Description visible 0 Visible on screen; the default value. invisible 1 Not displayed, but taken into account during layout gone 2 Completely hidden, as if the view had not been added.

What is the difference between invisible and gone for the view visibility status?

INVISIBLE: This view is invisible, but it still takes up space for layout purposes. GONE: This view is invisible, and it doesn't take any space for layout purposes.

How do I set visibility to disappear on Android?

try that setVisible(0) to visible true . and setVisible(4) to visible false. the text can be invisible but the button and datepicker no.

How do I set Visibility gone in Kotlin?

Android developers have added an extension androidx. core. view. ViewKt#isVisible to toggle visibility between View.


1 Answers

You got misconcept I think,

0 stands for VISIBLE..You can check here Developer Doc

0 is for VISIBLE
4 is for INVISIBLE 
8 is for GONE

So nothing going wrong in your case,Its working properly as per you passed the parameter.

like image 176
MKJParekh Avatar answered Oct 03 '22 22:10

MKJParekh