Android YogaLayout does not recalculate its dimension for any runtime change in children dimension #1168
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
Issues and Steps to Reproduce
Hi team,
We are facing a major issue with using YogaLayout android.
Issue:
Whenever the dimension of the child of YogaLayout changes dynamically, then the YogaLayout never recalculates its dimension for the change in child's dimension.
For.eg. Let us say we have a YogaLayout (with height/width = WRAP_CONTENT) has two children with ImageView (height/width = WRAP_CONTENT) and TextView (height/width = WRAP_CONTENT) in flex direction = Column. And we download the image from a url and load into the image view, when image is downloaded, then ImageView dimension changes, but the parent YogaLayout never adjusts its height and it renders the children in previously calculated height, as a result, the bottom text view gets cropped off.
I tried to mark the yogaNode of ImageView as dirty to re-render but no luck.
This issue has been haunting us for long time, and this is limits us to not to use YogaLayout as child of RecyclerView.
Please help
Expected Behavior
YogaLayout to recalculate its dimensions for any change in child's dimension
Actual Behavior
YogaLayout does not recalculate its dimensions for any change in child's dimension
Link to Code
If you have some code that maintainers can clone/test for themselves, bugs can be resolved much faster. Please paste a link here.
When applicable, use this fiddle to post a web repro.
Thanks for filing this. It's a bit tricky to tell what might be happening from your description. Would you be willing to provide a minimal repro of the issue?
To set expectations, the
YogaLayout
ViewGroup hasn't seen much attention recently, even compared to the overall layout engine, so we might not be able to give a quick turnaround for this issue.@NickGerleman Thank you very much getting back
I have created a sample project here: https://github.com/SanthoshKandalu/YogaIssueDemo
Can you please help?
@SanthoshKandalu it looks like you are not invalidating the parent like here. In order to kick of a layout recalculation for Android:
40db73d1a8/android/sample/java/com/facebook/samples/yoga/BenchmarkFragment.java (L42)
@woehrl01 - Thanks for checking.
I tried that yet no luck. You can see the changes in line 38 of FirstFragment.kt in my demo app.
Can you please help?
Please try putting the text inside another container, just to verify if it doesn't hit a different error.
FYI: I haven't used Yoga inside Android, yet.
@woehrl01 - I tried to wrap the text inside another container - LinearLayout or YogaLayout, but same ui behaviour as the screenshot attached above.
i have the same problem, i use yogalayout as item in RecycleView,and the item seem to be clipped as above, do u have any solution?
We'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.