简体   繁体   中英

Make bottom layout stay on bottom when keyboard is displayed while other layouts move up

Under you will the screenshots illustrating the starting layout, my current result which I am NOT happy with, and the result I want to have:

This is the opening layout which is perfect:

在此处输入图片说明

Then comes the current layout I get when displaying the keyboard which I am NOT happy with:

在此处输入图片说明

Then the result that I WANT:

在此处输入图片说明

Is the a line of code that will make the bottom layout ignore the android:windowSoftInputMode="stateVisible|adjustResize" ? Or how can I do this?

UPDATE:

This is what I get with adjustPan :

在此处输入图片说明

because you are using

adjustResize ,

So the window is getting resize to make space for keyboard you should use

android:windowSoftInputMode="adjustPan"

with this window will not resize and current focus will never obscured by the keyboard and users can always see what they are typing.

set android:layout_alignParentBottom="true" in your Layout for example ScrollView in my layout

add in manifest

android:windowSoftInputMode="adjustResize"

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/main_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white"
    android:gravity="top"
    android:orientation="horizontal"
    android:visibility="visible"
    android:weightSum="1">



    <ScrollView
        android:id="@+id/scrollView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/btn_search"
        android:padding="10dp"
        android:scrollbars="none">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">


        </LinearLayout>
    </ScrollView>

    <Button
        android:id="@+id/btn_search"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_gravity="center"
        android:layout_marginBottom="10dp"
        android:padding="15dp"
        android:text="@string/test_search"
        android:textAllCaps="false"
        android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM