title: Android layout set two buttons centered vertically and horizontally
body: <p>I'm developing an Android application.</p>
  
  <p>I'm trying to set buttons save and close centered, but they appear to the left.</p>
  
  <p>Here is my XML layout code:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="wrap_content"
      android:layout_height="fill_parent"
      android:orientation="vertical"&gt;
  
      &lt;TextView
          android:id="@+id/dialogGameName"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:gravity="center"
          android:layout_marginBottom="2sp"
          android:layout_marginLeft="5sp"
          android:layout_marginRight="5sp"
          android:layout_marginTop="5sp"
          android:typeface="sans"
          android:textSize="26sp"
          android:textStyle="bold"/&gt;
      &lt;TextView
          android:id="@+id/dialogGameDescription"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:gravity="left"
          android:layout_marginBottom="5sp"
          android:layout_marginLeft="5sp"
          android:layout_marginRight="5sp"
          android:layout_marginTop="2sp"
          android:typeface="monospace"
          android:textSize="18sp"/&gt;
  
      &lt;LinearLayout
          xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:orientation="horizontal"
          android:layout_gravity="center_vertical|center_horizontal"&gt;
          &lt;Button
              android:id="@+id/registerGameButton"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="@string/save"
              android:gravity="center"
              android:layout_marginBottom="5sp"
              android:layout_marginLeft="5sp"
              android:layout_marginRight="2sp"
              android:layout_marginTop="0sp" /&gt;
          &lt;Button
              android:id="@+id/closeButton"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="@string/close" 
              android:gravity="center"
              android:layout_marginBottom="5sp"
              android:layout_marginLeft="2sp"
              android:layout_marginRight="5sp"
              android:layout_marginTop="0sp"/&gt;
      &lt;/LinearLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>