android - 如何在按下 EditText 时阻止 Scrollview 将背景图像移动到顶部?

标签 android android-layout scrollview

我有一个背景图像,它具有 RelativeLayout 作为它的父级和兄弟级,因为 ScrollView 和 ScrollView 有一个 EditText。
当我们单击 Edittext 时,我面临背景图像移动顶部的问题。请在下面找到代码 fragment 和附加的屏幕截图。我们如何限制 ScrollView 这样做?

代码:

<ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:src="@drawable/dog"
        android:scaleType="centerCrop"/>

<ScrollView
        android:id="@+id/layout_scroll"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        android:visibility="visible">

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


        <EditText
                android:id="@+id/postal_code"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Postcode"
        />


    </RelativeLayout>
</ScrollView>

之前:

enter image description here

之后:

enter image description here

最佳答案

在 Activity list 中添加这个

android:windowSoftInputMode="adjustNothing"

关于android - 如何在按下 EditText 时阻止 Scrollview 将背景图像移动到顶部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59774530/

相关文章:

android - 如何将后退按钮放在 ActionBar 的左侧

Android - XML 布局与编程

ios - 如何同时使用水平和垂直 ScrollView (快速)

android - 日期选择器不会在 ScrollView 中滚动

java - 滚动浏览 RecyclerView

android - 随着电话分辨率的提高响应式网页设计

java - 当我添加意式 Espresso 时出现资源错误

Android JNI,有什么方法C++代码可以直接读取应用程序的sqlite数据库吗?

android - 如何动态添加布局文件

android - 如何在android studio中添加图标图像按钮