[英]Android soft keyboard hides RecyclerView
我正在嘗試使用RecyclerView
和底部的固定EditText
進行評論/聊天布局。 請不要說adjustPan
或adjustResize
。 不工作。 adjustPan
隱藏鍵盤。
我真的需要幫助,這真的很令人沮喪
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/appbarlayout"
android:paddingTop="@dimen/app_bar_top_padding">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:theme="@style/ThemeOverlay.AppCompat.ActionBar"
android:id="@+id/toolbar"
app:titleTextColor="#FFFFFF" />
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/recycler_view"
android:layout_below="@+id/appbarlayout"
android:isScrollContainer="false"
android:stackFromBottom="true"
android:transcriptMode="normal"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#2b2b2b"
android:orientation="vertical"
android:id="@+id/chat_box"
android:layout_alignParentBottom="true">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/listDivider"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Skriv en kommentar"
android:background="@android:color/transparent"
android:textColor="@color/white"
android:textColorHint="#d4d4d4"
android:inputType="textCapSentences|textMultiLine"
android:layout_marginRight="40dp"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_send"
android:background="@drawable/click"
android:layout_gravity="right|center_vertical" />
</FrameLayout>
</LinearLayout>
</RelativeLayout>
不知道為什么,但 Gabe Sechan 給出的解決方案對我不起作用。 對我有用的是在清單文件中添加它。
android:windowSoftInputMode="adjustPan"
我的 Recyclerview 正在隨着鍵盤移動,我當然不想這樣做。
第一種方法是在清單文件中設置android:windowSoftInputMode="adjustResize"
,但沒有成功。
但是我的第二種方法android:windowSoftInputMode="adjustPan"
正如@Kishan Solanki提到的那樣。
我的布局是一個約束,它包含了一個相對於我的 recyclerview 的約束
正確答案是adjustResize,因此應用程序在鍵盤上方調整大小。 但是,要使其工作,您的布局的其余部分需要編寫為可調整大小。 你的不是,因為回收者視圖沒有固定到位。 在它layout_above="@+id/chatBox"
添加一個layout_above="@+id/chatBox"
約束,使其位於編輯文本上方,並且它應該調整大小以正確適應空間。
此外,adjustPan 不會隱藏鍵盤。 如果是這樣,那么您的代碼確實有問題。 adjustPan 在不調整大小的情況下向上滑動您的應用程序。 如果您能找出應用程序中隱藏鍵盤的內容,這可能就是您想要的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.