Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>
like image 829
bvk256 Avatar asked May 11 '16 12:05

bvk256


People also ask

How do I keep the button on the bottom of my screen Android?

Make the Parent of the LinearLayout containing the button as relative and set the property of linear layout containing two buttons as android:layout_alignParentBottom="true". You can also set the gravity of the Linear Layout to Bottom. Save this answer.

How do I stop my keyboard from pushing up my screen?

How do I stop my keyboard from pushing up my screen? Add android:windowSoftInputMode="stateHidden|adjustPan" in required activity of your manifest file . This makes keyboard appear overlaying content, without making layout to recalculate it's height.


1 Answers

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.

like image 196
Jay Rathod RJ Avatar answered Oct 19 '22 19:10

Jay Rathod RJ