Q:

smooth scrolling for recyclerview

I got some problems in scrolling the recyclerview. I added the smoothScrollToPosition method to LinearLayoutManager but it didn't change anything.I tried to added the attribute named app:fastScrollEnabled but it caused error. I want a smooth scrolling. What should i do? Thank you in advance :)
XML Code:
  <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <android.support.v7.widget.Toolbar
        android:id="@+id/stu_toolbar"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:background="#a653a3"
        app:layout_scrollFlags="scroll|enterAlways">

        <ImageView
            android:id="@+id/check_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="left"
            android:layout_margin="@dimen/normal_margin"
            android:src="@drawable/ic_done_white_24dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right"
            android:layout_marginRight="@dimen/normal_margin"
            android:text="دانش آموزان"
            android:textSize="20sp" />

    </android.support.v7.widget.Toolbar>

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collpase_view_pager"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_scrollFlags="scroll|enterAlways">

        <android.support.v4.view.ViewPager
            android:id="@+id/slide_show"
            android:layout_width="match_parent"
            android:layout_height="150dp" />

    </android.support.design.widget.CollapsingToolbarLayout>

</android.support.design.widget.AppBarLayout>

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycle2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</android.support.v4.widget.NestedScrollView>

</android.support.design.widget.CoordinatorLayout>

Java Code:
public class Student extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.student_list);

    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycle2);
    LinearLayoutManager layoutManager = new LinearLayoutManager(this) {

        @Override
        public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
            LinearSmoothScroller smoothScroller = new LinearSmoothScroller(Student.this) {

                private static final float SPEED = 300f;

                @Override
                protected float calculateSpeedPerPixel(DisplayMetrics displayMetrics) {
                    return SPEED / displayMetrics.densityDpi;
                }

            };
            smoothScroller.setTargetPosition(position);
            startSmoothScroll(smoothScroller);
        }

    };
    recyclerView.setLayoutManager(layoutManager);
    AdapterSTList adapterSTList = new AdapterSTList(this, Generator.getStudents());
    recyclerView.setAdapter(adapterSTList);
    ViewPager viewPager = (ViewPager) findViewById(R.id.slide_show);
    ImageView check_btn = (ImageView) findViewById(R.id.check_button);
    ViewPagerAdapter viewPagerAdapter = new ViewPagerAdapter(this);
    viewPager.setAdapter(viewPagerAdapter);

    check_btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(Student.this,Main.class);
            startActivity(intent);
        }
    });
}
}

A:

Its because your recycler view is inside a nested Scroll view.
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior">

<android.support.v7.widget.RecyclerView
    android:id="@+id/recycle2"
    android:nestedScrollingEnabled="false"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

also in your code do this to support older devices :
 recyclerView.setNestedScrollingEnabled(false);

