bvk256
bvk256

Reputation: 1893

How to make button stay on the bottom when soft keyboard goes up

I have a button at the bottom of the screen and I want it to stay down even if soft keyboard goes up, but currently it goes up with soft keyboard. I tried to align the button to bottom but with no success.

Here is the code (buttons are within id/activity_form_button_frame):

<RelativeLayout>
     <RelativeLayout
        android:id="@+id/activity_form_button_frame"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true">
    <ImageButton
        android:id="@+id/activity_form_next_button"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@android:color/black"
        android:src="@drawable/next_btn_drawable"
        android:scaleType="fitCenter"
        android:padding="5dp"
        />
    <Button
        android:id="@+id/activity_form_sumbit_button"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@android:color/black"
        android:text="SUBMIT"
        android:textColor="@color/buttonBlue"
        android:visibility="gone"
        android:padding="15dp"
        style="@android:style/TextAppearance.Large"/>
    </RelativeLayout>

    <FrameLayout
        android:id="@+id/activity_form_fragmentcontainer"
        android:layout_below="@id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@id/activity_form_button_frame"/>

    </RelativeLayout>

Upvotes: 14

Views: 9678

Answers (10)

Sharad
Sharad

Reputation: 607

In my case, I was using <item name="android:windowFullscreen">true</item> in my theme. It was creating problem and I used android:windowSoftInputMode="adjustResize" along with that.

Upvotes: 0

UserSharma
UserSharma

Reputation: 488

You can use android:layout_alignParentBottom="true" for that.

Upvotes: -4

vennila mayavel
vennila mayavel

Reputation: 71

try this....

<activity
android:windowSoftInputMode="adjustPan">

Upvotes: 3

Kiruthika
Kiruthika

Reputation: 61

Try this

<activity
android:windowSoftInputMode="adjustPan">

or in code

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

Upvotes: 3

kaktus23
kaktus23

Reputation: 39

Try add in manifest to your activity attribute android:windowSoftInputMode. Set it to adjustResize or adjustPan. One of these will work.

Upvotes: 1

Jay Rathod
Jay Rathod

Reputation: 11245

In AndroidManifest.xml, set android:windowSoftInputMode="adjustPan" to your activity.

Like this.

<activity
    android:windowSoftInputMode="adjustPan">

Or:

<activity
    android:windowSoftInputMode="adjustPan|adjustResize">

Also you can do this Programmatically.

Use this code in onCreate() method:

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

Check this for Reference.

Upvotes: 20

Android Geek
Android Geek

Reputation: 9225

In your AndroidManifest.xml try this code:

<activity
            android:name="com.facebook.FacebookActivity"
            android:windowSoftInputMode="adjustPan|adjustResize"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.Translucent.NoTitleBar" />

Upvotes: 0

Mrugesh
Mrugesh

Reputation: 4517

In your manifest file under activity tag add the following line.

android:windowSoftInputMode="adjustPan|adjustResize"

Upvotes: 0

Hardik Parmar
Hardik Parmar

Reputation: 712

Change at your AndroidManifest file and at activity to add property like

android:windowSoftInputMode="adjustResize"

to this direct to open keyboard to above button.

Upvotes: 0

V-rund Puro-hit
V-rund Puro-hit

Reputation: 5534

Inside your manifest file under your activity tag just add this line.

android:windowSoftInputMode="stateHidden|adjustResize"

For Example,

<activity
    android:name="packagename.ClassName"
    android:label="@string/app_name"
    android:windowSoftInputMode="stateHidden|adjustResize" >
</activity>

And you are good to go.

Upvotes: 0

Related Questions