Skip to content Skip to sidebar Skip to footer

How To Set A Button At A Fixed Location On The Bottom Of Ui?

I want a button to appear at fixed location all the time, in the footer of the UI ؟ ( always, if it has components above it or not )

Solution 1:

Please take one Relative layout under your main layout . Set its height and width as fill parent and set its gravity as bottom and put any textview or any button you want in it.

<?xml version="1.0" encoding="utf-8"?><FrameLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent"><RelativeLayoutandroid:layout_width="fill_parent"android:layout_height="fill_parent"android:gravity="bottom"><Buttonandroid:layout_width="fill_parent"android:layout_height="wrap_content"android:text="Bottom Gravity" /></RelativeLayout><LinearLayoutandroid:layout_width="fill_parent"android:layout_height="wrap_content"><Buttonandroid:layout_width="fill_parent"android:layout_height="wrap_content"android:text="Without Gravity" /></LinearLayout></FrameLayout>

enter image description here

Solution 2:

It depends on the layout you are using.

On a RelativeLayout there is

android:layout_alignParentBottom="true"

On a LinearLayout, place it at the bottom and make sure to set the elements layout_weight properly.

Also, check the property

android:layout_gravity

and notice it's different than

android:gravity

Solution 3:

Set android:layout_gravity="bottom". Hope this helps.

Solution 4:

Put

android:layout_alignParentBottom="true"

in your relative layout.

Solution 5:

if any one have two button you can just make this it orks for me

<RelativeLayoutandroid:layout_width="fill_parent"android:layout_height="fill_parent"android:gravity="bottom"><LinearLayoutandroid:orientation="vertical"android:layout_width="match_parent"android:layout_height="wrap_content"android:gravity="bottom" ><android.support.v7.widget.AppCompatButtonandroid:id="@+id/btn_yes"android:layout_width="match_parent"android:layout_height="wrap_content"android:padding="12dp"android:text="Valider"/><android.support.v7.widget.AppCompatButtonandroid:id="@+id/btn_no"android:layout_width="match_parent"android:layout_height="wrap_content"android:padding="12dp"android:text="Annuler"/></LinearLayout></RelativeLayout>`

Post a Comment for "How To Set A Button At A Fixed Location On The Bottom Of Ui?"