如何使用调整Pan滚动布局



我的fragment中有一个nestedscrollview,它有nestedscrollview下面的按钮,当键盘到达时,按钮移动到键盘上方,整个布局正确处理其滚动,但问题出在背景图像上,它变小了。

我在清单文件中使用了android:windowSoftInputMode="stateAlwaysHidden|adjustResize",如果我使用adjustPan则视图不会向上滚动整个布局移位。

我知道这个问题被问了很多次,但我没有找到正确的答案。 请帮忙。

按照以下步骤操作: 之后,您就可以实现您想要的:(下面的代码是 MainActivity.xml 代码)在此代码中,图像视图是您的背景图像。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorAppBack"
tools:context=".activities.LoginActivity">
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none">
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/login_image_min_2" />
</ScrollView>
// Your container layout which contains fragments like framelayout or what ever you are using
</RelativeLayout>

在清单中:

android:windowSoftInputMode="adjustResize"

您的图像正在缩小,因为您在滚动视图中也添加了图像。 尝试在滚动视图的一侧添加图像,因为图像是背景图像。 这样图像就不会滚动。

最新更新