当前位置: 首页 > 工具软件 > Gravity View > 使用案例 >

IllegalArgumentException: No drawer view found with gravity LEFT

戚鸿福
2023-12-01
java.lang.IllegalArgumentException: No drawer view found with gravity LEFT
	at android.support.v4.widget.DrawerLayout.openDrawer(DrawerLayout.java:1639)
	at android.support.v4.widget.DrawerLayout.openDrawer(DrawerLayout.java:1625)
	at com.layout.mj.mvp.ui.MainActivity$nr.onClick(MainActivity.kt:90)
	at android.view.View.performClick(View.java:4471)
	at android.view.View$PerformClick.run(View.java:18778)
	at android.os.Handler.handleCallback(Handler.java:808)
	at android.os.Handler.dispatchMessage(Handler.java:103)
	at android.os.Looper.loop(Looper.java:193)
	at android.app.ActivityThread.main(ActivityThread.java:5345)
	at java.lang.reflect.Method.invokeNative(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:515)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
	at dalvik.system.NativeStart.main(Native Method)
<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:minHeight="?attr/actionBarSize"
        android:background="?attr/colorPrimary"/>

    <FrameLayout
        android:id="@+id/content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

    </LinearLayout>

    <fragment
        android:id="@+id/navigation"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:name="com.xyz.ui.navigation.NavigationFragment"
        tools:layout="@layout/fragment_navigation" />

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

在使用DrawerLayout的时候,Drawer通常使用match_parent和固定的宽度,并使用start代替left,因为left代表绝对的左边,而start可以根据当地的习惯(如从右向左阅读的国家就代表右边)来确定代表左边还是右边。

 类似资料:

相关阅读

相关文章

相关问答