简体   繁体   English

在android java中显示软键盘时,布局不会向上移动或平移

[英]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 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 的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. 从我的源代码中可以看出,我添加了fitsSystemWindows和windowSoftInputMode。

Can anyone please help me? 谁能帮帮我吗?

add ScrollView as parent of RelativeLayout.It is not proper answer but it will work. 添加ScrollView作为RelativeLayout的父级。它不是正确的答案,但它会工作。

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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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