Android – remove view and hidden view from parent view

In Android, if I remove the view from its parent view and hide the child view in the parent view (gone is not visible), I know that the hidden view will still remain in memory, but will the physical appearance of the parent view be different? If the answer is not different, does that mean that when I hide the child view, the whole layout of the child view basically does not exist in the parent view?

resolvent:

There are two things that go first can't be seen

When you use go to change visibility

But on the other hand, when you use invisible to change visibility

So the real problem is remove vs go

Remove

When you delete a view, it will be deleted from the hierarchy of the layout. This means that it is no longer a child of its parent. Therefore, the view can now be used in any other ViewGroup

to pass away

When you change the visibility to go, it becomes invisible and deletes the allocated space, but it is still a child of its parent. Therefore, it cannot be used in any other ViewGroup because a child can only have one parent

When to use delete

For me, if I want to move the view to another ViewGroup or hide it permanently, I must delete the view

When to use go

When you want to switch the visibility, please switch the visibility and the allocated space in the parent view. After setting the visibility to go, the user cannot distinguish whether a view exists first

When to use stealth

Similar to gone, when you want to switch visibility but don't want to delete the allocated space in the parent view, the UI looks as if it is hidden

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>