Центрировать несколько элементов в RelativeLayout, не помещая их в контейнер?

У меня есть RelativeLayout, содержащий пару расположенных рядом кнопок, которые я хочу расположить по центру макета. Я мог бы просто поместить кнопки в LinearLayout и центрировать их в RelativeLayout, но я хочу, чтобы мой xml был как можно более чистым.

Вот что я пробовал: кнопка «Применить» просто помещается в центр, а кнопка «Отменить» - слева от нее:

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="15sp">
  <TextView
    android:id="@+id/instructions"
    android:text="@string/instructions"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="15sp"
    android:layout_centerHorizontal="true"
    />
  <Button
    android:id="@+id/apply"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:text="@string/apply"
    android:textSize="20sp"
    android:layout_below="@id/instructions"
    />
  <Button
    android:id="@+id/undo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:text="@string/undo"
    android:textSize="20sp"
    android:layout_toLeftOf="@id/apply"
    android:layout_below="@id/instructions"
    />
</RelativeLayout>
38
задан herpderp 17 December 2011 в 00:25
поделиться