Android xml not support wrap_reverse and setVisibility(GONE) not work #1227

Closed
opened 2023-02-16 04:10:37 -08:00 by TChengZ · 5 comments
TChengZ commented 2023-02-16 04:10:37 -08:00 (Migrated from github.com)

Report

  • I have searched existing issues and this is not a duplicate
    i found two bug in Android
    1、yg_wrap not support "wrap_reverse"
    image
    image
    2、when use YogaLayout, view.setVisibility(GONE) by code or xml both won't work
    image
    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.

# Report - [ ] I have searched [existing issues](https://github.com/facebook/yoga/issues) and this is not a duplicate i found two bug in Android 1、yg_wrap not support "wrap_reverse" ![image](https://user-images.githubusercontent.com/2180654/219360412-ee118735-f8c1-49f7-bdaf-993037d190e6.png) ![image](https://user-images.githubusercontent.com/2180654/219360437-71511732-3cbc-4284-b1bf-d075924375a2.png) 2、when use YogaLayout, view.setVisibility(GONE) by code or xml both won't work ![image](https://user-images.githubusercontent.com/2180654/219360812-09991ab4-224a-437e-aa9e-fd6923bba6bb.png) 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](https://jsfiddle.net/emilsjolander/jckmwztt/) to post a web repro.***
NickGerleman commented 2023-03-04 08:10:06 -08:00 (Migrated from github.com)

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:

  1. 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.
  2. Similarly, yg_{} attributes only ever effect layout. So yg_display will make your views zero-sized, but will not remove them from screen reader, focus loops, or any performance optimizations reliant on android:visibility="gone'.

So, TLDR, under the current model you need to do both, and also manage other scenarios around invalidating the Yoga tree.

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: 1. `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. 2. Similarly, `yg_{}` attributes only ever effect layout. So `yg_display` will make your views zero-sized, but will not remove them from screen reader, focus loops, or any performance optimizations reliant on `android:visibility="gone'`. So, TLDR, under the current model you need to do both, and also manage other scenarios around invalidating the Yoga tree.
NickGerleman commented 2023-03-04 08:14:56 -08:00 (Migrated from github.com)

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 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.
TChengZ commented 2023-03-05 22:39:24 -08:00 (Migrated from github.com)

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。

> 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。
NickGerleman commented 2023-03-06 00:49:25 -08:00 (Migrated from github.com)

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-layout

> 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](https://fblitho.com/) 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-layout
NickGerleman commented 2023-04-25 20:44:48 -07:00 (Migrated from github.com)

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.

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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DaddyFrosty/yoga#1227
No description provided.