package com.example.myapplication.mvvm; import android.content.Context; import android.util.AttributeSet; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.PagerSnapHelper; import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.SnapHelper; public class DYLinearLayout extends LinearLayoutManager { PagerSnapHelper helper; public DYLinearLayout(Context context) { super(context); } public DYLinearLayout(Context context, int orientation, boolean reverseLayout) { super(context, orientation, reverseLayout); } public DYLinearLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } @Override public void onAttachedToWindow(RecyclerView view) { super.onAttachedToWindow(view); if (helper == null) { helper = new PagerSnapHelper(); } helper.attachToRecyclerView(view); SnapHelper snapHelper = new PagerSnapHelper(); // snapHelper.attachToRecyclerView(helper.recyNavigation); // helper.recyNavigation.setOnFlingListener(null); } }