简体   繁体   中英

Margin Left in Constraint Layout on Android does not work

I have tried to set the margins to a ConstraintSet into the ConstraintSet.LEFT anchor. But it doesn't work. However when using the ConstraintSet.START anchor, it works.

I am using constraints programmatically, and I tried setting the margins with both ConstraintSet.connect , as in:

(Does't work)

set.connect(view.getId(), ConstraintSet.LEFT, ConstraintSet.PARENT_ID, ConstraintSet.LEFT, MARGIN);

(Works)

set.connect(view.getId(), ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START, MARGIN);

And, I also tried with ConstraintSet.setMargin , as in:

(Doesn't work)

set.setMargin(view.getId(), ConstraintSet.LEFT, MARGIN);

(Works)

set.setMargin(view.getId(), ConstraintSet.START, MARGIN);

您必须使用START和END

set.setMargin(view.getId(), ConstraintSet.START, MARGIN);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM