简体   繁体   English

具有EditText的RecyclerView

[英]RecyclerView with EditText

I have a RecyclerView whose elements contain EditText with focusable = false . 我有一个RecyclerView其元素包含具有focusable = false EditText On a special event, I make one of them focused (focusable = true, focusableInTouchMode = true, requestFocus) , and then I show the onscreen keyboard. 在一个特殊事件上,我将其中一个聚焦(focusable = true, focusableInTouchMode = true, requestFocus) ,然后显示屏幕键盘。 In this case, the application area becomes significantly smaller in height due to the keyboard and some of the RecyclerView items are no longer visible and therefore destroyed. 在这种情况下,由于键盘的作​​用,应用程序区域的高度明显变小,并且某些RecyclerView项不再可见并因此被破坏。 The problem is that if the edited element is close to the bottom of the screen, then it is destroyed and the user can not edit it. 问题是,如果已编辑的元素靠近屏幕底部,则该元素将被破坏,并且用户无法对其进行编辑。 A simple scrollToPosition does not help, because without the on-screen keyboard, the element is already visible on the screen and no scrolling occurs. 简单的scrollToPosition没有帮助,因为如果没有屏幕键盘,则该元素已经在屏幕上可见并且不会发生滚动。

How can I avoid the disappearance of the item being edited? 如何避免正在编辑的项目消失?

Will you try this: 您可以尝试一下:

<activity
    ......
    android:windowSoftInputMode="adjustResize"
    ...... >
</activity>

In your manifest under activity(which has recycler view) tag, add above property. 在活动(具有回收者视图)标签下的清单中,添加上述属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM