rubensousa / GravitySnapHelper

A SnapHelper that snaps a RecyclerView to an edge.
Apache License 2.0
5k stars 615 forks source link

at RecyclerView nested(嵌套) RecyclerView,an interesting problem.... #51

Closed ZengHongHua closed 5 years ago

ZengHongHua commented 6 years ago

I have a problem, at RecyclerView nested(嵌套) RecyclerView, It creates an interesting problem, It's been rocking there. can you help me,thank you very much. this is the video connection: https://res.cloudinary.com/liuyuesha/video/upload/v1540888109/test_snap_b2aa9s.mp4

Part of the code: @Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, final int position) {

    if (holder instanceof RecommendSongsHolder) {

        FindBean.ModulesBean modulesBean = mFindDataList.get(position);
        List<FindRecommendSongInfo> program_list = modulesBean.getData().getTrack_list();

        LinearLayoutManager manager = new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false);
        ((RecommendSongsHolder) holder).recyclerView.setLayoutManager(manager);
        ((RecommendSongsHolder) holder).recyclerView.setHasFixedSize(true);
        ((RecommendSongsHolder) holder).recyclerView.setNestedScrollingEnabled(false);
        RecommendSongsChildAdapter songsChildAdapter = new RecommendSongsChildAdapter(mContext, mActivity, program_list, mDeviceDialog);
        ((RecommendSongsHolder) holder).recyclerView.setAdapter(songsChildAdapter);

        ((RecommendSongsHolder) holder).recyclerView.setOnFlingListener(null);
        SnapHelper snapHelper = new GravitySnapHelper(Gravity.START);
        snapHelper.attachToRecyclerView(((RecommendSongsHolder) holder).recyclerView);

    }
rubensousa commented 6 years ago

Do you have padding in your recyclerview? Can you share your layout's XML here?

ZengHongHua commented 6 years ago
      Do you have padding in your recyclerview? Can you share your layout's XML here?

oh yes,I have set padding. <RecyclerView android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingStart="20dp" >

ZengHongHua commented 6 years ago

code in my conpany, RecyclerView layout like this: RecyclerView android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingStart="20dp"

rubensousa commented 6 years ago

Does it still happen if you remove the padding? I've been working on a fix for this tonight. Check the develop branch code and see if it works for you until I release the new version.

ZengHongHua commented 6 years ago

I remove the padding, it is ok.

rubensousa commented 6 years ago

Great :) Will keep this open until 2.0 is released.

rubensousa commented 5 years ago

Fixed in 2.0