我在導航抽屜中有一個ListView和兩個ImageButton。我的問題是,如果我的列表視圖展開超出屏幕,它會滾動顯示所有列表視圖項目,而不是下面的兩個圖像按鈕。在導航抽屜中使用ScrollView
爲了解決這個問題,我嘗試添加ScrollView來包裝LinearLayout(@ + id/drawer),但它給了我下面的錯誤。
是否有可能有一個NavDrawer額外的項目(除了listview),並有一個整體滾動?
<FrameLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ScrollView
android:layout_width="240dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/texturebg2"
android:layout_gravity="start">
<LinearLayout
android:id="@+id/drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/texturebg2"
android:layout_gravity="start">
<ListView
android:id="@+id/list_slidermenu"
android:layout_width="240dp"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@color/col3"
android:dividerHeight="1dp"
android:listSelector="@drawable/menu_selector" />
<LinearLayout
android:id="@+id/extrabuttons"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:gravity="center_horizontal|bottom"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp" >
<ImageButton
android:id="@+id/credit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription = "@string/credit"
android:onClick="openCredit"
android:src="@drawable/information"
android:background="@drawable/mybutton2"
android:padding="8dip"
android:text="@string/credit" />
<ImageButton
android:id="@+id/exit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription = "@string/exit"
android:onClick="closeApp"
android:src="@drawable/ic_exit"
android:background="@drawable/mybutton2"
android:padding="8dip"
android:layout_marginLeft="10dp"
android:text="@string/exit" />
</LinearLayout>
</LinearLayout>
</ScrollView>
logcat的
01-09 14:04:02.446: E/AndroidRuntime(1072): FATAL EXCEPTION: main
01-09 14:04:02.446: E/AndroidRuntime(1072): Process: com.migrationdesk.mylibman, PID: 1072
01-09 14:04:02.446: E/AndroidRuntime(1072): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.migrationdesk.mylibman/com.migrationdesk.mylibman.NavContainer}: java.lang.ClassCastException: android.widget.FrameLayout$LayoutParams cannot be cast to android.support.v4.widget.DrawerLayout$LayoutParams
01-09 14:04:02.446: E/AndroidRuntime(1072): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176)
01-09 14:04:02.446: E/AndroidRuntime(1072): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
01-09 14:04:02.446: E/AndroidRuntime(1072): at android.app.ActivityThread.access$700(ActivityThread.java:135)
01-09 14:04:02.446: E/AndroidRuntime(1072): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
01-09 14:04:02.446: E/AndroidRuntime(1072): at android.os.Handler.dispatchMessage(Handler.java:102)
01-09 14:04:02.446: E/AndroidRuntime(1072): at android.os.Looper.loop(Looper.java:137)
01-09 14:04:02.446: E/AndroidRuntime(1072): at android.app.ActivityThread.main(ActivityThread.java:4998)
01-09 14:04:02.446: E/AndroidRuntime(1072): at java.lang.reflect.Method.invokeNative(Native Method)
01-09 14:04:02.446: E/AndroidRuntime(1072): at java.lang.reflect.Method.invoke(Method.java:515)
01-09 14:04:02.446: E/AndroidRuntime(1072): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
01-09 14:04:02.446: E/AndroidRuntime(1072): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
01-09 14:04:02.446: E/AndroidRuntime(1072): at dalvik.system.NativeStart.main(Native Method)
01-09 14:04:02.446: E/AndroidRuntime(1072): Caused by: java.lang.ClassCastException: android.widget.FrameLayout$LayoutParams cannot be cast to android.support.v4.widget.DrawerLayout$LayoutParams
01-09 14:04:02.446: E/AndroidRuntime(1072): at android.support.v4.widget.DrawerLayout.isDrawerView(DrawerLayout.java:857)
01-09 14:04:02.446: E/AndroidRuntime(1072): at android.support.v4.widget.DrawerLayout.closeDrawer(DrawerLayout.java:1058)
01-09 14:04:02.446: E/AndroidRuntime(1072): at com.migrationdesk.mylibman.NavContainer.displayView(NavContainer.java:202)
01-09 14:04:02.446: E/AndroidRuntime(1072): at com.migrationdesk.mylibman.NavContainer.onCreate(NavContainer.java:116)
01-09 14:04:02.446: E/AndroidRuntime(1072): at android.app.Activity.performCreate(Activity.java:5243)
01-09 14:04:02.446: E/AndroidRuntime(1072): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
01-09 14:04:02.446: E/AndroidRuntime(1072): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
01-09 14:04:02.446: E/AndroidRuntime(1072): ... 11 more
後的完整的堆棧跟蹤的代碼大小?爲什麼你想在這裏使用framelayout? – Triode
更新... framelayout是我的碎片的容器...這是我如何找到所有教程abour NavDrawer ... – abdfahim