How to center a View inside of an Android Layout?

后端 未结 10 1457
深忆病人
深忆病人 2020-12-07 18:18

I want to put a layout in the center of the screen.

10条回答
  •  被撕碎了的回忆
    2020-12-07 19:01

    Step #1: Wrap whatever it is you want centered on the screen in a full-screen RelativeLayout.

    Step #2: Give that child view (the one, which you want centered inside the RelativeLayout) the android:layout_centerInParent="true" attribute.

提交回复
热议问题