Android YogaLayout set setVisibility to View.GONE problem #671
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Report
When I set a YoagLayout to View.GONE. It still takes the space and give it back to its parent. I already try invalidate(view), requestLayout on YoagLayout and its parent YoagLayout.
Issues and Steps to Reproduce
Please see the xml and code below. Just click the change button and it will show or hide the content of YogaLayout1. But when it hides it, the space is still reserved and not given back to its parent. This never happens when I used Android LinearLayout as the container.
The only way to make the YogaLayout give back its space is to remove it from its parent YogaLayout. But when I add it back when I want to show it, it is not displayed properly. Please see the screen shots below.
Expected Behavior
When we set yogalayout Visibility to View.GONE, it should not take its space any more.
Actual Behavior
The yogalayout still takes the space.




Following pictures are in order of:
1-initial screen
2-after setVisibility to View.GONE
3-use removeview approach
4- after removing the yogalayout and add it back in its parent yogalayout at index 0.
Link to Code
https://gist.github.com/AndrewYangmq/4be91e3031863a487448bb3ca02d620d
hey @AndrewYangmq did you find some solution about this?
I alse meet this problem, is anyone find some solution?
in
YogaLayout.ViewMeasureFunction#measure
,changeif (view == null || view instanceof YogaLayout) { return YogaMeasureOutput.make(0, 0); }
toif (view == null || view instanceof YogaLayout || view.getVisibility() == GONE){.....}
but when a child View in YogaLayout,it's unuseful!!
hello,I'm back。
I found the way to fix this bug.
In
,when add a child ,if it's
GONE
,we save the current index, the code likethen we add a function to change the Child's visibility,and add it‘s YogaNode to correct index,and calculate it's parent
YogaNode
,the code likeWe're deprecating the
com.facebook.yoga.android.YogaLayout
ViewGroup in the next major release of Yoga. We intend to still push out a new version aligned to the core Yoga 2.0. I have bulk closed ViewGroup issues to reflect that we are not planning to invest time into functional changes of the ViewGroup. and eventually intend to remove it from the repo.