我正在尝试在导航抽屉中实现水平回收视图。它工作得很好,除了向左滑动,导航抽屉被关闭的事实。有没有办法阻止导航抽屉在用户与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>
感谢您的帮助!