Android - YogaLayout not working inside ScrollView #435

Closed
opened 2017-02-22 23:36:41 -08:00 by birfincankafein · 5 comments
birfincankafein commented 2017-02-22 23:36:41 -08:00 (Migrated from github.com)

Report

Expected Behavior

YogaLayout inside ScrollView should be visible event I set width.

Actual Behavior

When you set width to ScrollView node, the content becomes invisible. I checked with Hierarchy Viewer the content has 0 height and 0 width.

Link to Code

YogaLayout innerLayout = new YogaLayout(getActivity());
innerLayout.setLayoutParams(new YogaLayout.LayoutParams(-1,-1));
innerLayout.setBackgroundColor(Color.RED);

YogaNode scrollViewNode = new YogaNode();
ScrollView scrollView = new ScrollView(getActivity());
scrollView.setBackgroundColor(Color.GREEN);

scrollViewNode.setHeight(250);
scrollViewNode.setWidth(250);
// when you set maxWidth instead of setWidth its working. 

YogaLayout inner1Layout = new YogaLayout(getActivity());
YogaNode inner1LayoutNode = inner1Layout.getYogaNode();
inner1Layout.setBackgroundColor(Color.BLUE);
inner1LayoutNode.setWidth(100);
inner1LayoutNode.setHeight(1000);
scrollView.addView(inner1Layout);
innerLayout.addView(scrollView, scrollViewNode);
innerLayoutNode.calculateLayout(innerLayoutNode.getWidth().value, innerLayoutNode.getHeight().value);

# Report - [x] I have searched [existing issues](https://github.com/facebook/yoga/issues) and this is not a duplicate # Expected Behavior YogaLayout inside ScrollView should be visible event I set width. # Actual Behavior When you set width to ScrollView node, the content becomes invisible. I checked with Hierarchy Viewer the content has 0 height and 0 width. # Link to Code ``` YogaLayout innerLayout = new YogaLayout(getActivity()); innerLayout.setLayoutParams(new YogaLayout.LayoutParams(-1,-1)); innerLayout.setBackgroundColor(Color.RED); YogaNode scrollViewNode = new YogaNode(); ScrollView scrollView = new ScrollView(getActivity()); scrollView.setBackgroundColor(Color.GREEN); scrollViewNode.setHeight(250); scrollViewNode.setWidth(250); // when you set maxWidth instead of setWidth its working. YogaLayout inner1Layout = new YogaLayout(getActivity()); YogaNode inner1LayoutNode = inner1Layout.getYogaNode(); inner1Layout.setBackgroundColor(Color.BLUE); inner1LayoutNode.setWidth(100); inner1LayoutNode.setHeight(1000); scrollView.addView(inner1Layout); innerLayout.addView(scrollView, scrollViewNode); innerLayoutNode.calculateLayout(innerLayoutNode.getWidth().value, innerLayoutNode.getHeight().value); ```
emilsjolander commented 2017-02-24 07:05:12 -08:00 (Migrated from github.com)

Thanks for the report! Most likely need to set overflow:scroll on the scrollview node. Possibly a bug in the bindings. Maybe the bindings could even do this on behalf of the user by detecting if it is a scroll container.

Thanks for the report! Most likely need to set overflow:scroll on the scrollview node. Possibly a bug in the bindings. Maybe the bindings could even do this on behalf of the user by detecting if it is a scroll container.
birfincankafein commented 2017-02-25 08:56:34 -08:00 (Migrated from github.com)

When you use native container inside YogaLayout, you will face this issue probably. For example I tried SearchView too. It has LinearLayout inside. The content inside LinearLayout not calculated and has 0 height width. I checked them with Hierarchy Viewer.

When you use native container inside YogaLayout, you will face this issue probably. For example I tried SearchView too. It has LinearLayout inside. The content inside LinearLayout not calculated and has 0 height width. I checked them with Hierarchy Viewer.
rspencer01 commented 2017-03-11 15:00:05 -08:00 (Migrated from github.com)

This might also be a (lack of) invalidation error. That is, the root node is measured at size 0,0 and never remeasured. Are you ever calling invalidateView?

This might also be a (lack of) invalidation error. That is, the root node is measured at size 0,0 and never remeasured. Are you ever calling `invalidateView`?
uziasferreirazup commented 2020-09-23 13:12:50 -07:00 (Migrated from github.com)

Does someone resolve this problem?

Does someone resolve this problem?
NickGerleman commented 2023-04-25 20:43:39 -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#435
No description provided.