Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set a button at a fixed location on the bottom of UI?

Tags:

android

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 )

like image 604
Adham Avatar asked Jun 29 '11 10:06

Adham


People also ask

How do I place a fixed button at the bottom right of the screen in HTML?

A simple problem but many new developers don't know how to do this. Set CSS Position property to fixed, bottom and right properties to 0px. Use cases : A feedback button or a chat window.

How do you place a button at the bottom of the screen in android?

From Settings, go to System, Gestures, and then tap System Navigation. Gesture navigation will be selected by default, but you can tap 3-button navigation to make buttons appear at the bottom of your screen.

How do I change the position of a button in linear layout?

You can set the android:layout_weight='1' and both buttons will share the screen equally(side by side) or if you want the extra space between them, you can place a button each in a linear layout and set the android:layout_gravity to left and right for each. Save this answer.


2 Answers

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"?>
<FrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent">

    <RelativeLayout 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        android:gravity="bottom">

        <Button 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:text="Bottom Gravity" />

    </RelativeLayout>

    <LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <Button 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:text="Without Gravity" />

    </LinearLayout>

</FrameLayout>

enter image description here

like image 120
Chirag Avatar answered Oct 14 '22 08:10

Chirag


Put

android:layout_alignParentBottom="true"

in your relative layout.

like image 23
jigar Avatar answered Oct 14 '22 08:10

jigar