Android 程序运行崩溃:Resource is not a drawable (color or path)

本文介绍了如何解决Android应用中因自定义style缺少parent属性而导致的异常问题。通过检查manifest文件及style配置,确保所有自定义style都有正确的parent属性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 解决办法:

1.检查manifest是否使用了自定义style。

2.检查自定义style 是否有parent,没有的话会导致这个异常,将parent 属性加上


     错误代码:

 

             修改方法就是上面所说的将 style background 添加parent属性

我做了一个安卓画板app现在添加了一个从url下载图片并设置成画板背板的功能。我把代码给你看,在我输入了https://www.nottingham.edu.cn/image-library/campus-news/signofnottingham.jpg的网站后提示下载失败 /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cn.edu.nottingham.jianxingwang.fingerpainter; import android.content.ContentResolver; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Path; import android.net.Uri; import android.os.Bundle; import android.os.Parcelable; import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; import android.view.View; import android.widget.Button; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Stack; /** * Created by pszmdf on 13/10/16. * * Derived from android graphics API sample com.example.android.apis.graphics.Fingerpaint * android.googlesource.com/platform/development/+/master/samples/ApiDemos/src/com/example/android/apis/graphics/FingerPaint.java * */ public class FingerPainterView extends View { private Context context; private Canvas canvas; private Paint paint; private Bitmap bitmap; private Path path; private Uri uri; private Stack<Bitmap> undoStack = new
最新发布
03-29
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值