Why Does Recyclerview Scroll To Top Of View When View Is Focused
Solution 1:
I found a solution, I extended LinearLayoutManager and override some methods. Now it not scrolling to focused items. Maybe someone knows better solution?
publicclassNotScrollingToFocuesChildrenLinearLayoutManagerextendsLinearLayoutManager {
publicNotScrollingToFocuesChildrenLinearLayoutManager(Context context) {
super(context);
}
publicNotScrollingToFocuesChildrenLinearLayoutManager(Context context, int orientation, boolean reverseLayout) {
super(context, orientation, reverseLayout);
}
publicNotScrollingToFocuesChildrenLinearLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
@OverridepublicbooleanonRequestChildFocus(RecyclerView parent, RecyclerView.State state, View child, View focused) {
//return super.onRequestChildFocus(parent, state, child, focused);returntrue;
}
@OverridepublicbooleanonRequestChildFocus(RecyclerView parent, View child, View focused) {
//return super.onRequestChildFocus(parent, child, focused);returntrue;
}
}
Solution 2:
This answer might be your solution as well: RecyclerView scrolls to top after keyboard hides
<activity
android:windowSoftInputMode="adjustPan"
"adjustResize"
The activity's main window is always resized to make room for the soft keyboard on screen.
"adjustPan"
The activity's main window is not resized to make room for the soft keyboard. Rather, the contents of the window are automatically panned so that the current focus is never obscured by the keyboard and users can always see what they are typing. This is generally less desirable than resizing, because the user may need to close the soft keyboard to get at and interact with obscured parts of the window.
Post a Comment for "Why Does Recyclerview Scroll To Top Of View When View Is Focused"