Closed Sinyuk7 closed 1 year ago
At the moment you'll have to use linkTo(start, end, ..., bias)
. See ConstrainScope.linkTo.
But since it's not always the most convenient way, we'll make all those parameters available at the property level.
Opps...I almost lost a linkTo
method here in [ConstrainScope]. I thought only a Anchorable
reference has linkTo
method, which has limited parameters:
fun linkTo(
anchor: ConstraintLayoutBaseScope.HorizontalAnchor,
margin: Dp = 0.dp,
goneMargin: Dp = 0.dp
)
thanks for reply!
Hi, in Compose, if I arrange 3 Boxes vertically, and the middle Box depends on the upper and lower 2 Boxes:
Then if I want to make Box 2 as close as possible to Box 1 or Box 3, this is easy to do in Xml by setting its bias:
But in Compose, the only thing I can find related to the keyword "bias" is
ChainStyle.Pack()
. UnfortunatelyChain
overrides Box's original constraints (Although I know that is what is written in the Compose code)createVerticalChain(box2)
createVerticalChain(box1, box2, box3)
Of course, in alternative way, I can put Box2 in a "FrameLayout" and using its alignment to achieve “bias”. And this FrameLayout replaces the original Box2's position in the ConstraintLayout.
Well this approach is obviously not elegant, I'm wondering if I'm using Chain incorrectly, or if there are other ways to achieve a similar effect