如何使用AdjustPan滚动布局

时间:2019-02-20 07:33:01

标签: android

我的nestedscrollview中有一个fragment,其中的按钮位于nestedscrollview下方,当键盘到达时,按钮移至键盘上方,并且整个布局均能正确滚动,但问题出在与背景图片一起缩小。

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

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

2 个答案:

答案 0 :(得分:3)

请按照以下步骤操作: 之后,您便可以实现所需的功能(下面的代码是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"

答案 1 :(得分:0)

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

相关问题