How to center multiple Views together using ConstraintLayout?

前端 未结 5 493
野的像风
野的像风 2021-02-01 12:17

Background

Google has announced a new layout called \"ConstraintLayout\" that\'s supposed to be the ultimate layout, that could replace all of the layouts while stayin

5条回答
  •  醉话见心
    2021-02-01 12:29

    To center something vertically or horizontally, set an opposing constraint on the layout.

    Centered Vertically

        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
    

    Centered Horizontally

        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
    

提交回复
热议问题