gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 11:51:04 24 4
gpt4 key购买 nike

我想在显示键盘时调整大小或平移布局。这是我的源代码。

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>

ma​​nifest.xml

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

正如您从我的源代码中看到的,我添加了fitsSystemWindows 和windowSoftInputMode。

谁能帮帮我吗?

最佳答案

添加ScrollView作为RelativeLayout的父级。这不是正确的答案,但它会起作用。

示例

    <?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>

关于java - 当 android java 中显示软键盘时,布局不会向上移动或平移,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41828299/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com