Nested RecyclerView like Google Play Store App

前端 未结 1 1008
难免孤独
难免孤独 2020-12-16 14:28

I am currently working on replicating the UI pattern implemented in the Play Store App. For implementing such a behavior, I have used a Vertical RecyclerView as

相关标签:
1条回答
  • 2020-12-16 15:06

    Here's a tutorial for implementing such RecyclerView. You might also consider looking at the github repository as well.

    The idea is to disable the touch detection of the outer RecyclerView when the inner RecyclerView is touched. See the implementation here in the parent RecyclerView adapter class.

    // Disable touch detection for parent recyclerView if we use vertical nested recyclerViews
    private View.OnTouchListener mTouchListener = new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            v.getParent().requestDisallowInterceptTouchEvent(true);
            return false;
        }
    }; 
    

    And then set the touch listener to the view.

    view.findViewById(R.id.recyclerView).setOnTouchListener(mTouchListener);
    
    0 讨论(0)
提交回复
热议问题