android / codelab-constraint-layout

Constraint Layout Codelab
https://codelabs.developers.google.com/codelabs/constraint-layout/
Apache License 2.0
471 stars 242 forks source link

2.0.0beta4-2.0.0 bug: Layouts disappear due to width/height 0 when visibility is changed and view then animates in #91

Open arberg opened 4 years ago

arberg commented 4 years ago

Works in : implementation "androidx.constraintlayout:constraintlayout:1.1.3" Others: I didn't try beta5 in my 'binary' search, and alpha4, beta1 failed with linking error) Fails in : implementation "androidx.constraintlayout:constraintlayout:2.0.0-beta4" Fails in : implementation "androidx.constraintlayout:constraintlayout:2.0.0-beta6" Fails in : implementation "androidx.constraintlayout:constraintlayout:2.0.0-beta7" Fails in : implementation "androidx.constraintlayout:constraintlayout:2.0.0-beta8" Fails in : implementation "androidx.constraintlayout:constraintlayout:2.0.0"

Subviews of constraint-layout sometimes vanish when their visibility is changed from gone->visible. So showing/hiding views in constraint layout seems broken, which if true is a major issue.

It is very likely related to the flickering of this issue, as this also appeared first time in beta8, and it could be related to same dissapearing trick: https://github.com/googlecodelabs/constraint-layout/issues/87

When the views have vanished and I connect the android studio 4.0.0 layout inspector it shows width/height=0 and sometimes incorrect x coordinate, and correctly with visibibility visible. I can only reproduce the bug when layout inspector is not in live mode. The flickering which is probably that mentioned in issue 87 is sometimes visible as views dissapear, because they blink in and out of existence. The flickering also cannot be seen in live mode of layout inspector.

See two layouts in which I have seen this problem. I have removed sibling layouts of the complex named one, but not parent layouts in this file.

I suspect the issue is only present when the visibility change is made when layout parent layout is set to animate in to screen.

I have check for when in-animation completes, and then calls request layout on all constraint-layouts in the tree being animated in. Now views appear once animation finishes. This also indicates its a bug in the ConstraintLayout and not my usage of it. I use viewBindings to change the visibility of the views.

I'm by now pretty sure it works in 1.1.3, say 97 % sure, at least for how I use it. I may just have failed to reproduce it, though by now I can do it fairly easy.

complex-panel.xml.txt simpler-panel.xml.txt

applantern commented 4 years ago

Ups, this is not the right bugtracker. I have placed it here:

https://issuetracker.google.com/issues/166486013

atulgpt commented 3 years ago

@arberg This issue is fixed under https://issuetracker.google.com/issues/166486013 We can close this bug cc @applantern