https://kotlinlang.org logo
#android
Title
# android
d

dewildte

04/03/2020, 3:51 PM
Say I have Views A, B and C. A is baselined to C. C is then set to GONE. Is there a way in XML to change A's baseline alignment to B in that scenario? (edited)  Like a 
app:gone_baseline="some_other_view_than_this_one"
c

Cody Engel

04/03/2020, 4:00 PM
You could look at doing it programmatically, but I’m not sure that would be the best route. Is it possible that both A and C should have some relationship with B so when C is gone A falls back to B? Barriers sound like another possibile solution https://constraintlayout.com/basics/barriers.html
e

Eric

04/03/2020, 5:13 PM
How about using Guideline in Constraintlayout? View A -> Guideline, View C -> Guideline?
c

Cody Engel

04/03/2020, 5:22 PM
Guidelines work if you want some pre-defined grid (which is typically enough). Barriers are nice when you want two or more views to determine the maximum width/height of an area. I’ve only used barriers a few times though so could be butchering that explanation
d

dewildte

04/04/2020, 3:43 AM
I accomplished it programmatically.
It was honestly the easiest way to do it.
It ended up being a more complicated problem then I described and I just ended up manipulating the View's constraints programatically.
Constraint layout API's are pretty good actually.