当我在安装了Android版6.0.1的手机上运行我的应用程序时,它运行得很完美,但是在安装了Android 4.4.4版本的手机上运行相同的应用程序时 然后它显示以下错误:
<?xml version="1.0" encoding="utf-8"?<android.support.v4.widget.DrawerLayout 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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<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_header_main">
<!--app:menu="@menu/activity_main_drawer"-->
<LinearLayout
android:orientation="vertical"
android:layout_marginTop="@dimen/nav_header_height"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:src="@mipmap/ic_person_black_24dp"/>
<TextView
android:id="@+id/nav_profile"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingStart="20dp"
android:textSize="15sp"
android:text="Profile"
android:onClick="gotoprofile"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/writelayout">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:src="@mipmap/ic_mode_edit_black_24dp"/>
<TextView
android:id="@+id/write"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingStart="20dp"
android:textSize="15sp"
android:text="Write"
android:onClick="gotowrite"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/deletelayout">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:src="@mipmap/ic_delete_black_24dp"/>
<TextView
android:id="@+id/delete"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingStart="20dp"
android:textSize="15sp"
android:text="Delete"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/logoutlayout">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:src="@mipmap/ic_exit_to_app_black_24dp"/>
<TextView
android:id="@+id/logout"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingStart="20dp"
android:textSize="15sp"
android:text="Logout"
android:onClick="gotowrite"
/>
</LinearLayout>
<ExpandableListView
android:id="@+id/left_drawer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:groupIndicator="@mipmap/ic_arrow_drop_down_black_24dp"
android:indicatorStart="200dp"
android:indicatorRight="230dp"
android:background="#FFFF"
android:dividerHeight="0dp" />
</LinearLayout>
</android.support.design.widget.NavigationView>
以下是使用导航视图的布局的xml代码
<?xml version="1.0" encoding="utf-8"?><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:layout_height="@dimen/nav_header_height"
android:background="@drawable/profilebackgrd"
android:orientation="vertical"
android:paddingBottom="12dp"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="30dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginLeft="15dp"
android:layout_marginBottom="12dp"
android:src="@drawable/user_image"
android:id="@+id/etuserimage" />
<TextView
android:id="@+id/user100"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="User Name"
android:textSize="20sp"
android:textColor="#000000"
android:layout_marginLeft="23dp"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
这是我正在使用的nav_header_main文件,它具有圆形图像视图
{{1}}
答案 0 :(得分:1)
真正的错误是 android.content.res.Resources $ NotFoundException:资源不是Drawable(颜色或路径)它意味着你使用的矢量图像不支持我的你的Android操作系统设备
Android 4.4(API级别20)及更低版本不支持矢量绘图。如果您的最低API级别设置为其中一个API级别,则在使用Vector Asset Studio时有两个选项:生成可移植网络图形(PNG)文件(默认)或使用支持库。
如果您只想使用矢量绘图,可以使用Android支持库23.2或更高版本。此技术需要在运行Vector Asset Studio之前更改build.gradle文件,如支持库向后兼容性中所述。支持库中的VectorDrawableCompat类允许您在Android 2.1(API级别7)及更高版本中支持VectorDrawable。 This Link会为您提供更多帮助。