Use RecyclerView inside ScrollView with flexible Recycler item height

后端 未结 8 1679
误落风尘
误落风尘 2020-11-29 04:57

I want to know if there is any possible way to use RecyclerView?

Before this, I used RecyclerView with fixed height inside a

8条回答
  •  猫巷女王i
    2020-11-29 05:11

    In case setting fixed height for the RecyclerView didn't work for someone (like me), here is what I've added to the fixed height solution:

       mRecyclerView.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
        @Override
        public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
            int action = e.getAction();
            switch (action) {
            case MotionEvent.ACTION_MOVE:
                rv.getParent().requestDisallowInterceptTouchEvent(true);
                break;
        }
        return false;
    }
    
    @Override
    public void onTouchEvent(RecyclerView rv, MotionEvent e) {
    
    }
    
    @Override
    public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
    
        }
    });
    

    I

提交回复
热议问题