2017-01-28 4 views
0

ナビゲーションドロワーを作成しました。ナビゲーションドロワのメインコンテンツにRecyclerViewがありますが、スクロールしていません。最初はRecyclerViewをNestedScrollViewなしで配置しましたが、動作しませんでしたので、NestedScrollView内に配置しようとしましたが、後者は動作しませんでした。Recyclerビューがナビゲーションドロワーでスクロールしていません

マイナビ引き出しXMLは次のとおりです。

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.roushan.assignment1.NavDrawerActivity"> 

    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/nav_toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="@color/nav_toolbar_color" 
      app:popupTheme="@style/AppTheme.PopupOverlay" /> 

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

    <!-- MAIN CONTENT OF NAVIGATION DRAWER ACTIVITY --> 
    <android.support.v4.widget.NestedScrollView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:fillViewport="true" 
      app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

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

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

    <android.support.v4.widget.DrawerLayout 
     android:id="@+id/drawer_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginTop="56dp" 
     tools:openDrawer="start"> 

     <android.support.design.widget.NavigationView 
      android:id="@+id/nav_view" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_gravity="start" 
      android:fitsSystemWindows="true" 
      app:headerLayout="@layout/nav_drawer_header" 
      app:menu="@menu/activity_nav_drawer_drawer" > 


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

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

</RelativeLayout> 
+0

メインコンテンツは 'の前に' 'の中に入ります。また、必ずしも 'NestedScrollView'は必要ありません。 –

+0

それは働いて..ありがとう.. –

+0

問題はありません。 [下の回答を受け入れる](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work)を実行してください。問題が解決した場合は、矢印の下にあるチェックマークを押してください。乾杯! –

答えて

1

マイクが指摘したように、あなたはレイアウトを構造化している方法が間違っています。以下のようにレイアウトを変更してください:

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.roushan.assignment1.NavDrawerActivity"> 

    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/nav_toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="@color/nav_toolbar_color" 
      app:popupTheme="@style/AppTheme.PopupOverlay" /> 

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

    <android.support.v4.widget.DrawerLayout 
     android:id="@+id/drawer_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginTop="56dp" 
     tools:openDrawer="start"> 

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

     <android.support.design.widget.NavigationView 
      android:id="@+id/nav_view" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_gravity="start" 
      android:fitsSystemWindows="true" 
      app:headerLayout="@layout/nav_drawer_header" 
      app:menu="@menu/activity_nav_drawer_drawer" > 
     </android.support.design.widget.NavigationView> 

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

</RelativeLayout> 
+0

ありがとう..私の一日を救った.. –

関連する問題