How to put a Button at the bottom of the screen ? - Android Development

· 40 words · 1 minute read

the whole gravity / layout_gravity is a bit confusing, so here is a snippet:

<LinearLayout android:layout_width="fill_parent"

            android:layout_height="fill_parent"

            android:orientation="horizontal"

            android:gravity="center_horizontal|bottom">

            <Button

                android:layout_width="wrap_content"

                android:layout_height="wrap_content"

                android:text="  Back  "

                android:id="@+id/btn_back"/>
</LinearLayout>

The line of code that makes the button at the bottom is android:gravity="center_horizontal|bottom".

Share:
waffarx cash back