Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/207.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何重置NavigationView滚动位置_Android_Navigation Drawer_Drawerlayout - Fatal编程技术网

Android 如何重置NavigationView滚动位置

Android 如何重置NavigationView滚动位置,android,navigation-drawer,drawerlayout,Android,Navigation Drawer,Drawerlayout,我有如下导航视图 <android.support.design.widget.NavigationView android:id="@+id/navigation" style="@style/NavDrawer" android:layout_height="match_parent" android:layout_gravity="start" android:fitsSystemWindows="tru

我有如下导航视图

<android.support.design.widget.NavigationView
        android:id="@+id/navigation"
        style="@style/NavDrawer"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:itemBackground="@android:color/transparent"
        app:itemTextColor="@color/drawer_item">

        <ExpandableListView
            android:id="@+id/list_navigation_menu"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="@dimen/list_view_marigin_top"
            android:divider="@android:color/transparent"
            android:dividerHeight="@dimen/list_view_divider_height"
            android:fitsSystemWindows="true"
            android:listSelector="@android:color/transparent"
            android:visibility="gone" />

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recycler_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="@dimen/list_view_marigin_top"
            android:fitsSystemWindows="true" />
    </android.support.design.widget.NavigationView>

这个解决方案对我有效 RecyclerView.getLayoutManager().scrollToPosition(0)

  ((NavigationMenuView)((NavigationView)mViewHolder.mNavigationView).getChildAt(0)).scrollToPosition(0);

    mViewHolder.mNavigationView.scrollTo(0,0);

    mViewHolder.mNavigationView.setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_DEFAULT);