【问题标题】:Error inflating class NavigationView膨胀类 NavigationView 时出错
【发布时间】:2015-08-27 21:13:52
【问题描述】:

运行我的应用程序时出现此错误。有任何想法吗 ?我正在使用 Android Studio 和 SDK 22。

Process: com.example.sv_laptop03.app, PID: 21717
java.lang.RuntimeException: 
Unable to start activity ComponentInfo{com.example.sv_laptop03.app/com.example.sv_laptop03.app.LoggedIn}: android.view.InflateException:Binary XML file line #123: Error inflating class android.support.design.widget.NavigationView

这是它所指的xml:

        <android.support.design.widget.NavigationView
        android:id="@+id/navigation_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="left"
        app:headerLayout="@layout/headerview"
        app:menu="@menu/drawer"
        app:itemTextColor="#ffffff"/>
     </android.support.v4.widget.DrawerLayout>

Headerview.xml :Headerview.xml :Headerview.xml :Headerview.xml :Headerview.xml :Headerview.xml :

         <LinearLayout        xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:background="@drawable/headerbg"
    android:layout_height="200dp"
    android:orientation="vertical"><!--
    <TextView
        android:id="@+id/profileName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="30sp"
        android:textColor="#ffffff"/>
-->
    <de.hdodenhof.circleimageview.CircleImageView
        android:id="@+id/profileImage"
        android:layout_width="90dp"
        android:layout_marginTop="10dp"
        android:src="@drawable/snapchainappicon"
        app:border_width="2dp"
        app:border_color="#2E7D32"
        android:layout_gravity="center"
        android:layout_height="90dp"/><!--

    <TextView
        android:id="@+id/viewProfile"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="15sp"
        android:text="View Profile"
        android:textColor="#ffffff"/>-->
     </LinearLayout>

这里是 XML FOR 菜单/抽屉。 xml文件

 <group android:checkableBehavior="single">
      <item
        android:id="@+id/itemAbout"
        android:title="How it works"
        android:icon="@drawable/ic_help_black_24dp"/>
    <item
        android:id="@+id/itemNetworks"
        android:title="Friends"
        android:icon="@drawable/ic_contacts_black_24dp"/>
    <item
        android:id="@+id/itemShare"
        android:title="Share"
        android:icon="@drawable/ic_share_black_24dp"/>
    <item
        android:id="@+id/itemSettings"
        android:title="Settings"
        android:icon="@drawable/ic_settings_black_24dp" />
    <item
        android:id="@+id/itemFeedback"
        android:title="Feedback"
        android:icon="@drawable/ic_feedback_black_24dp"/>
    <item
        android:id="@+id/itemLogOut"
        android:title="Log out"
        android:icon="@drawable/ic_power_settings_new_black_24dp"/>
     </group>
     </menu>

【问题讨论】:

  • 1.确保添加编译支持设计。 2.显示你的xml,可能你添加了一些错误的配置,所以布局创建失败。
  • 用xml更新了问题
  • 能否也显示@layout/headerview@menu/drawer的xml?
  • 现在将这些 xmls 添加到问题中
  • 您是否将compile 'de.hdodenhof:circleimageview:1.3.0' 添加到评分中? drawer xml 也缺少打开的 &lt;menu&gt; 标签,这只是复制错误吗?我复制了你的 xml,它可以工作

标签: java android navigationview


【解决方案1】:
  1. 检查您是否将活动添加到清单文件中
  2. 如果您在低端设备上尝试,可能会发生这种情况。

【讨论】:

  • 你是对的,它只是没有在低端模拟器上显示。在我的手机上运行良好。谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-11-29
  • 2017-02-28
  • 2021-07-10
  • 2020-08-01
  • 2016-02-28
相关资源
最近更新 更多