Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between foo.setVisibility(View.GONE) and parent.removeView(foo)

If foo is a view, what is the difference between foo.setVisibility(View.GONE) and fooParent.removeView(foo)? I am particularly interested in memory consumption of the view, before and after both statements.

Does a view with visibility set to GONE consume memory ?

like image 615
Syed Fahad Sultan Avatar asked Oct 01 '12 12:10

Syed Fahad Sultan


People also ask

What is the difference between VIEW gone and view invisible?

A View's visibility status is of Integer type and can have one of three options: VISIBLE (0) - The View is visible to the user. INVISIBLE (4) - The View is invisible to the user, but still takes up space in the layout. GONE (8) - The View is invisible, and it does not take up space in the layout.

What is difference between invisible and gone in Android?

When a View is gone, it means it doesn't take any space in the layout. When it is invisible, it will take the necessary room in a layout but you just don't see it.

What is view gone in Android?

View. GONE This view is invisible, and it doesn't take any space for layout purposes. View. INVISIBLE This view is invisible, but it still takes up space for layout purposes. In your example, you are overriding the View.

How do I make my Android visibility disappear?

You only need to add android:visibility=”gone” in the start constraintset (in the motionscene file) to do that. The default behavior we apply on visibility change plays on alpha channel as well as bounds.


1 Answers

If you need to remove them and then show them again, it could be better to just set visibility to gone and then change back to visible again.

If you on the other hand don't need them visible again, simply remove them.

like image 97
Chirag Avatar answered Sep 25 '22 07:09

Chirag