我插入背景图片时应用崩溃 [英] app is crashing when i am inserting background image

查看:116
本文介绍了我插入背景图片时应用崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我插入图像时,我的应用程序崩溃了,而当我编写android:background="@drawable/logo"时,我的应用程序也崩溃了

my app is crashing when I am inserting an image and I am not getting log report too when I am writing android:background="@drawable/logo" my app is crashing

<?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>

推荐答案

问题是您可能在比 API24 更低的API版本上进行测试.因此它将抛出ResourceNotFoundException,因为它不存在drawable.

The problem is you probably testing on lower API version then API24. So it will throw ResourceNotFoundException cause drawable does not exists for it .

因此,您必须拥有普通可绘制文件夹drawable的副本.或在所有drawable-v24,drawable-v21和drawable中.将drawable放在所有文件夹中,最重要的是放在drawable中.

可绘制
drawable-v21
drawable-v24

So You have to have a copy of it normal drawable folder drawable . Or in all drawable-v24, drawable-v21 and drawable . put the drawable in all folder most importantly in drawable.

drawable
drawable-v21
drawable-v24

这篇关于我插入背景图片时应用崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆