Nested Recyclerview scrolls by itself

前端 未结 7 806
情歌与酒
情歌与酒 2020-12-08 02:19

I have a parent recyclerview that has 3 child view in it. The last two of the child are recyclerview.

Parent recyclerview
 - child view 1
 - child view 2 (ho         


        
7条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-08 03:05

    Short hint to @albertvilacalvo answer: If you use RecyclerView programmatically, you may handle setFocusableInTouchMode that way (include in your RecyclerView class)

    @Override
    protected void onAttachedToWindow() {
       ((View) getParent()).setFocusableInTouchMode(true);
       super.onAttachedToWindow();
    }
    

    The descendantFocusability solution fails if you need EditText in your child views, they would not get cursor anymore. I'm using ListView, custom (multi)touch and EditText in my RecyclerView childs. No sideeffects using setFocusableInTouchMode so far.

提交回复
热议问题