当我插入背景图片时应用程序崩溃
app is crashing when i am inserting background image
我的应用程序在插入图像时崩溃,而我在写入时也没有收到日志报告android:background="@drawable/logo"
我的应用程序崩溃
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/rootLayout"
android:background="@drawable/logo"
tools:context="com.android.spotsdialog.MainActivity">
</RelativeLayout>
请输入崩溃文本或者您可以替换此代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context="com.android.spotsdialog.MainActivity"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/logo"
/>
</RelativeLayout >
问题是您可能在 API 版本然后 API24 上测试。所以它会抛出 ResourceNotFoundException
因为 drawable 不存在。
所以你必须有一个它的副本普通可绘制文件夹可绘制。或者在所有 drawable-v24、drawable-v21 和 drawable 中。将 drawable 放在所有文件夹中,最重要的是 drawable
.
可绘制
drawable-v21
drawable-v24
我的应用程序在插入图像时崩溃,而我在写入时也没有收到日志报告android:background="@drawable/logo"
我的应用程序崩溃
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/rootLayout"
android:background="@drawable/logo"
tools:context="com.android.spotsdialog.MainActivity">
</RelativeLayout>
请输入崩溃文本或者您可以替换此代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context="com.android.spotsdialog.MainActivity"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/logo"
/>
</RelativeLayout >
问题是您可能在 API 版本然后 API24 上测试。所以它会抛出 ResourceNotFoundException
因为 drawable 不存在。
所以你必须有一个它的副本普通可绘制文件夹可绘制。或者在所有 drawable-v24、drawable-v21 和 drawable 中。将 drawable 放在所有文件夹中,最重要的是 drawable
.
可绘制
drawable-v21
drawable-v24