导航抽屉中的水平Recyclerview

时间:2018-04-28 08:16:47

标签: android android-recyclerview android-navigation-drawer android-navigation

我正在尝试在导航抽屉中实现水平回收视图。它工作得很好,除了向左滑动,导航抽屉被关闭的事实。有没有办法阻止导航抽屉在用户与recyclerview交互时关闭?我试过这种方式:

    mNavigationRecyclerHourly.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            Log.d(TAG, "onTouch: ");
            switch (motionEvent.getAction()) {
                case MotionEvent.ACTION_DOWN: mDrawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN);
                    break;
                case MotionEvent.ACTION_MOVE: mDrawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN);
                    break;
                case MotionEvent.ACTION_UP: mDrawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
                    break;
            }
            return true;
        }

    });

Recyclerview xml:

    <android.support.v7.widget.RecyclerView
                    android:id="@+id/recyclerview_navigation_hourly"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/progress_navigation_uv"
                    android:scrollbars="horizontal"
                    android:overScrollMode="never"
                    android:scrollbarThumbHorizontal="@drawable/thumb_navigation"
                    android:layout_alignParentStart="true"
                    android:padding="8dp">
                    </android.support.v7.widget.RecyclerView>

感谢您的帮助!

0 个答案:

没有答案