我找到了一个解决方案,我扩展了 LinearLayoutManager 并重写了一些方法。现在它不会滚动到焦点项目。也许有人知道更好的解决方案?
public class NotScrollingToFocuesChildrenLinearLayoutManager extends LinearLayoutManager {
public NotScrollingToFocuesChildrenLinearLayoutManager(Context context) {
super(context);
}
public NotScrollingToFocuesChildrenLinearLayoutManager(Context context, int orientation, boolean reverseLayout) {
super(context, orientation, reverseLayout);
}
public NotScrollingToFocuesChildrenLinearLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
@Override
public boolean onRequestChildFocus(RecyclerView parent, RecyclerView.State state, View child, View focused) {
//return super.onRequestChildFocus(parent, state, child, focused);
return true;
}
@Override
public boolean onRequestChildFocus(RecyclerView parent, View child, View focused) {
//return super.onRequestChildFocus(parent, child, focused);
return true;
}
}