[英]InputType in EditText inside RecyclerView
在我的RecyclerrView
有些項目具有EditText(Inside cardView)
它在沒有在EditText
定義InputType
情況下可以正常工作,但是當我定義InputType時,當EditText
成為焦點時(當在editText
上editText
以輸入值時)它會使recyclerview
滾動到位置零。
這是默認的EditText
,可以正常工作
<EditText
android:id="@+id/et_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
android:layout_weight="1"
android:background="@drawable/box_blue_outline"
android:gravity="center"
android:hint="@string/name"
android:padding="@dimen/dp_5"
android:textSize="@dimen/sp_16" />
我還有另一個僅接受數字的EditText
,所以我添加了InputType
<EditText
android:id="@+id/et_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
android:layout_weight="1"
android:background="@drawable/box_blue_outline"
android:gravity="center"
android:inputType="number"
android:hint="@string/number"
android:padding="@dimen/dp_5"
android:textSize="@dimen/sp_16" />
但是單擊此EditText
以輸入值,該值在RecyclerView
之間(例如7)處於某個位置,它將滾動回到位置1。
看起來,不同的鍵盤更改導致RecyclerView
更新。 Window焦點類型很有可能。 嘗試更改鍵盤行為,使其出現在Activity/Fragment
onCreate
。
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
請包括所有View
布局, RecyclerView
以及要綁定的布局。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.