Sunday 18 November 2012

Android: Center align a button in a Linear layout xml

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:weightSum="1" >

                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:layout_weight="1"
                    android:weightSum="1">

                    <Button
                        android:id="@+id/working_hours_exit_btn"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_weight=".2"
                        android:background="@drawable/exit"
                        android:hint="@string/working_hours_exit_btn_hint" />
                </LinearLayout>
            </TableRow>

No comments:

Post a Comment