简体   繁体   中英

Layout not move up or panned when soft keyboard is shown in android java

I want to resize or pan layout when keyboard is displayed. Here's my source code.

activity_forget_password.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/forgot_password_bg"
        android:scaleType="fitXY"
        android:largeHeap="true"/>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="15dp">

        <com.opkix.app.utils.OpenSassTextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/forget_password_introduce_string"
            android:layout_alignParentBottom="true"
            android:textColor="@android:color/white"
            android:textSize="12sp"/>
    </RelativeLayout>
</RelativeLayout>

manifest.xml

<activity android:name=".activities.auth.ForgetPasswordActivity"
    android:windowSoftInputMode="adjustPan"
    android:noHistory="true">

As you can see from my source code I added fitsSystemWindows and windowSoftInputMode.

Can anyone please help me?

add ScrollView as parent of RelativeLayout.It is not proper answer but it will work.

example

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true">
 <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent">
     <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/forgot_password_bg"
            android:scaleType="fitXY"
            android:largeHeap="true"/>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="15dp">

            <com.opkix.app.utils.OpenSassTextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/forget_password_introduce_string"
                android:layout_alignParentBottom="true"
                android:textColor="@android:color/white"
                android:textSize="12sp"/>
        </RelativeLayout>
    </RelativeLayout>
    </ScrollView>
  </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