1

我有一個導航抽屜有問題。Android - 導航抽屜 - 滾動視圖沒有滾動

我不能滾動導航抽屜裏面 ...但我有足夠的項目在我的列表視圖。

我檢查了我的xml,但沒有找到任何問題的原因。

這裏就是ListView的定義我的 「主」 XML:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com /apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/fragView" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context=".Hauptmenue_extended" > 

<ListView 
    android:id="@+id/left_drawer" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="start" 
    android:background="#fff" /> 


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

這裏是我的代碼:

mDrawerLayout = (DrawerLayout) findViewById(R.id.fragView); 
     mDrawerList = (ListView) findViewById(R.id.left_drawer); 
     mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, 
       GravityCompat.START); 

     // Get the titles ... 
     drawerTitles = getResources().getStringArray(
       R.array.drawerTitles_array); 
     // Get the sub titles ... 
     drawerSubtitles = getResources().getStringArray(
       R.array.drawerSubtitles_array); 
     // Set the icons ... 
     drawerIcons = new int[] { R.drawable.icon_buergermeldung, 
       R.drawable.icon_sprechblase, 
       R.drawable.icon_action_settings_dark, R.drawable.icon_user_chat, R.drawable.icon_haus, R.drawable.icon_contact, R.drawable.icon_calendar, R.drawable.icon_search, R.drawable.icon_zaehlerstand }; 

     // Create new MenuListAdapter 
     MenuListAdapter mMenuAdapter = new MenuListAdapter(this, 
       drawerTitles, drawerSubtitles, drawerIcons); 

     mDrawerList.setAdapter(mMenuAdapter); 
     mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); 

     // Add Navigation Drawer to Action Bar 
     mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, 
       R.drawable.ic_drawer, R.string.drawer_open, 
       R.string.drawer_close) { 
      public void onDrawerClosed(View view) { 
       getSupportActionBar().setTitle(mTitle); 
       supportInvalidateOptionsMenu(); 
      } 

      public void onDrawerOpened(View drawerView) { 
       getSupportActionBar().setTitle(R.string.app_name); 
       supportInvalidateOptionsMenu(); 
      } 
     }; 
     mDrawerLayout.setDrawerListener(mDrawerToggle); 

誰能幫助我?

回答

3

嘗試使用NavigationDrawer instructions page中的XML代碼。有一些差異對我而言是突出的。例如,將ListView高度設置爲match_parent而不是wrap_content(奇怪,我知道),並確保爲內容包含FrameLayout。

<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <!-- The main content view --> 
    <FrameLayout 
     android:id="@+id/content_frame" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 
    <!-- The navigation drawer --> 
    <ListView android:id="@+id/left_drawer" 
     android:layout_width="240dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:choiceMode="singleChoice" 
     android:divider="@android:color/transparent" 
     android:dividerHeight="0dp" 
     android:background="#111"/> 
</android.support.v4.widget.DrawerLayout>