Android xml not support wrap_reverse and setVisibility(GONE) not work #1227
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
i found two bug in Android
1、yg_wrap not support "wrap_reverse"
2、when use YogaLayout, view.setVisibility(GONE) by code or xml both won't work
The ImageView above seem to be in "Invisible" state, unless add yoga:yg_display="none"
Issues and Steps to Reproduce
Replaces this with steps to repro your issue.
Expected Behavior
Describe what you expected would happen.
Actual Behavior
Describe what actually happened.
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.
Feel free to make a PR for #1, it seems like you already found where to define the missing attribute, and its source of truth.
For #2, it looks like:
YogaLayout.applyLayoutParams
, which transfers attributes to the underlying Yoga Node, only ever inputs from Yoga namespaced sources. So we do not read from Android standard ones as any input into layout calculation.yg_{}
attributes only ever effect layout. Soyg_display
will make your views zero-sized, but will not remove them from screen reader, focus loops, or any performance optimizations reliant onandroid:visibility="gone'
.So, TLDR, under the current model you need to do both, and also manage other scenarios around invalidating the Yoga tree.
I might also warn that the YogaLayout ViewGroup was not hardened as a production tool used by Meta, and I am personally unaware of large-scale production usages of it (though some may exist that I am not aware of).
From some of the issues I have seen from users, I have wondered if it might be better to deprecate it, since it's not a place I think will be prioritized. But I would like to learn more from someone who is using it, on what you are using it for, and how serious of an impact not releasing new versions of it would have.
i used yogalayout for its cross platform, if i only write an app for android,i will use constraintlayout, linearlayout support by Goolgle。But since i need run my code in both android, html and even linux,i need a cross platform ui engine to support all this which will make it much more easier to write layout once,and run it every。
Shameless plug, closer to the level of a "UI engine" than Yoga are frameworks like React Native using Yoga, where you write the same UI code between Android, iOS, web (there are also versions for macOS, Windows, but not GTK or Qt). https://snack.expo.dev/?platform=web
But I think Meta's own usage of Yoga for Android-compatibile cross-platform code has been to enable it in higher level UI libraries like React Native for React components, or Litho for writing native Android components which are powered by Yoga (also OSS, but more used internally to Meta).
For the specific case of Android, there is also a library which Google developed first with the goal of exposing flexbox constraints as an Android ViewGroup. I have not used it personally though, but as an example, they do receive
Visibility.GONE
as an input https://github.com/google/flexbox-layoutWe'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.