Saturday, August 27, 2011

Another Note to Self

In Android, to get things to center properly, use the android:gravity tag in the Layout surrounding it....


<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="horizontal"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:gravity="center">
 
<Button   android:text="Add"
          android:id="@+id/button_dialog_set"
          android:textStyle="bold"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          >
</Button>
<Button   android:text="Cancel"
          android:id="@+id/button_dialog_cancel"
          android:textStyle="bold"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          >
</Button>
</LinearLayout>


Produces two buttons, centered, next to each other

No comments:

Post a Comment