Android-layout zwei Tasten vertikal zentriert und horizontal

Ich bin die Entwicklung einer Android-Anwendung.

Ich versuche buttons speichern und schließen zentriert, aber Sie erscheinen auf der linken Seite.

Hier ist mein XML-layout-code:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:orientation="vertical">

    <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"/>
    <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"/>

    <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">
        <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" />
        <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"/>
    </LinearLayout>
</LinearLayout>
InformationsquelleAutor VansFannel | 2011-01-14
Schreibe einen Kommentar