How to center a View inside of an Android Layout?

Vicky picture Vicky · Sep 30, 2009 · Viewed 118k times · Source

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

Answer

CommonsWare picture CommonsWare · Oct 1, 2009

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.