Is it possible to in ConstrainLayout have two textviews constrained such that they take 50% of the space each if they need it, and if they don't the other grows to fill the space.
A Correct: When texts are short the textViews do not interfere with eachother.
B Correct: The short left textView yields space to the longer right one
C Correct: Share horizontal space equally and grow vertically
D Incorrect: Right textView grows on expense of the left textView.
E Incorrect: Right textView grows vertically rather than filling available horizontal space.
I've tried a lot of things. It think layout_width="wrap_content"
or layout_constraintWidth_default="wrap"
is a must since it is the textViews' only way to communicate how much space it wants.
Experimented with:
layout_constrainedWidth="true/false"
layout_constraintWidth_default="spread/wrap"
layout_constraintWidth_max="wrap"
layout_constraintHorizontal_weight="1" // with 0dp as width
Experimentation mostly with the textViews in a horizontal chain, since there is a symmetry in the problem I think a symmetric solution makes sense.
Has anyone managed this or is it just impossible? I do not know why it behaves as it does with the second element in the chain being 'heavier' than the first one forcing it to be the only one to grow vertically.
from ConstraintLayout with growing TextViews claiming equal space if needed
No comments:
Post a Comment