How to center a View inside of an Android Layout?

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

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

10条回答
  •  清歌不尽
    2020-12-07 19:06

    You can apply a centering to any View, including a Layout, by using the XML attribute android:layout_gravity". You probably want to give it the value "center".

    You can find a reference of possible values for this option here: http://developer.android.com/reference/android/widget/LinearLayout.LayoutParams.html#attr_android:layout_gravity

提交回复
热议问题