【问题标题】:Drawable crashing on Android 5 and lowerDrawable 在 Android 5 及更低版本上崩溃
【发布时间】:2018-11-01 15:08:44
【问题描述】:

所以我有一个 XML 类来给按钮圆角:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
    android:angle="225"
    android:startColor="#A5C938"
    android:endColor="#A5C938"/>
<corners
    android:bottomLeftRadius="7dp"
    android:bottomRightRadius="7dp"
    android:topLeftRadius="7dp"
    android:topRightRadius="7dp" />
</shape>

在较旧的设备上,当我通过以下方式引用此文件时,我遇到了一个崩溃,指出它不是可绘制的:android:background="@drawable/rounded_button"

               Caused by: android.content.res.Resources$NotFoundException: Resource "com.chimesoftware.chime.chimetimemanager:drawable/rounded_button" (7f0700ae)  is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f0700ae a=-1 r=0x7f0700ae}
                  at android.content.res.Resources.loadDrawableForCookie(Resources.java:4017)
                  at android.content.res.Resources.loadDrawable(Resources.java:3929)
                  at android.content.res.Resources.loadDrawable(Resources.java:3779)
                  at android.content.res.TypedArray.getDrawable(TypedArray.java:776)

【问题讨论】:

标签: java android xml drawable


【解决方案1】:

我正在检查应用程序现在是否在 SDK 23 及更高版本上,我发现这是在较低 SDK 上出现的错误。

【讨论】:

    【解决方案2】:

    检查你的drawable rounded_button是什么资源包 对于小屏幕设备,它应该在drawable-hdpi

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-06-24
      • 1970-01-01
      • 2017-01-17
      • 1970-01-01
      • 1970-01-01
      • 2015-10-13
      • 2016-09-10
      相关资源
      最近更新 更多