Reputation: 61
I've created this xml file, and I want to center the two buttons at the middle of the screen instead of showing them at the very top of the screen
<LinearLayout
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="@android:drawable/bottom_bar"
android:orientation="horizontal"
android:paddingBottom="1.0dip"
android:paddingLeft="4.0dip"
android:paddingRight="4.0dip"
android:paddingTop="5.0dip" >
<Button
android:id="@+id/allow"
android:layout_width="0.0dip"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:text="Allow" />
<Button
android:id="@+id/deny"
android:layout_width="0.0dip"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:text="Deny" />
</LinearLayout>
Upvotes: 0
Views: 119
Reputation: 3578
set gravity of Linear Layout.
<LinearLayout
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="@android:drawable/bottom_bar"
android:orientation="horizontal"
android:paddingBottom="1.0dip"
android:paddingLeft="4.0dip"
android:paddingRight="4.0dip"
android:paddingTop="5.0dip"
android:gravity="center_horizontal|center_vertical">
Upvotes: 1
Reputation: 9590
use android:layout_gravity="center_vertical|center_horizontal"
in both buttons to put in the center.
Upvotes: 1