portfoliobuilder
portfoliobuilder

Reputation: 7866

How to force button at bottom of view to move up with soft keyboard?

I have a button at the bottom of my view, and I would like that when my editText is interacted with that the button remains on top of the soft keyboard. How can I force this? Here is how my layout is formatted. Please also note that this is a fragment inside of a view pager (if that matters).

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/fl_parent"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        ... some code
    </LinearLayout>

    <!-- button at bottom -->
    <LinearLayout
        android:id="@+id/bottom_wrapper"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <!-- next button -->
        <Button
            android:id="@+id/btn_next"
            android:layout_width="match_parent"
            android:layout_height="54dp"
            android:layout_gravity="bottom" />
    </LinearLayout>
</FrameLayout>

Upvotes: 1

Views: 314

Answers (1)

Shishram
Shishram

Reputation: 1516

try adding this in your manifest.xml for particular Activity

android:windowSoftInputMode="adjustResize"

in manifest it will look like below code:-

<activity
         android:name=".YourActivity"
         android:label="@string/label"
         android:windowSoftInputMode="adjustResize">
        </activity>

Upvotes: 2

Related Questions