![](/img/trans.png)
[英]How to scroll my layout when setting android:windowSoftInputMode=“adjustPan”?
[英]How to scroll layout with adjustPan
我的fragment
有一個nestedscrollview
,其中的按鈕位於nestedscrollview
下方,當鍵盤到達時,按鈕在鍵盤上方移動,整個布局正確地滾動,但問題是背景圖像縮小了。
我在清單文件中使用了android:windowSoftInputMode="stateAlwaysHidden|adjustResize"
,如果我使用adjustPan
則視圖不會向上滾動整個布局。
我知道這個問題被問過很多次,但是我沒有找到正確的答案。 請幫忙。
請按照以下步驟進行操作:之后,您可以實現所需的功能(下面的代碼是MainActivity.xml代碼)。在此代碼中,Image View是您的背景圖片。
<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"
您的圖像正在縮小,因為您也已在滾動視圖中添加了圖像。 嘗試在滾動視圖之外添加圖像,因為圖像是背景圖像。 這樣,圖像將不會滾動。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.