Without animation on a RecyclerView element, select Android

I have a navigation box that uses a RecyclerView to display the title + list of items below. When the elements are clicked, a new fragment is called. My problem is that there is no animation.

This is my main.xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="match_parent">

<include
    android:id="@+id/toolbar"
    layout="@layout/toolbar" />

<android.support.v4.widget.DrawerLayout
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/navdrawer_listselector"
    android:layout_below="@id/toolbar">

    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="250dp"
        android:layout_height="match_parent"
        android:clickable="true"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:layout_gravity="start"
        android:background="@drawable/navdrawer_listselector"
        android:scrollbars="vertical" />

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

I set clickable, focusable and focusableInTouchMode to true, just like the background I set navdrawer_listselector, but it does not give any results.

This is how I implemented the recyclerView element listener:

recyclerView.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
        @Override
        public boolean onInterceptTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
            View child = recyclerView.findChildViewUnder(motionEvent.getX(), motionEvent.getY());
            if (child != null && gestureDetector.onTouchEvent(motionEvent)) {
                onNavItemSelected(recyclerView.getChildPosition(child));
                drawer.closeDrawers();
                return true;

            }
            return false;
        }

        @Override
        public void onTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {

        }
    });

What's wrong?

+4
source share

All Articles