首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >找不到类android.graphics.drawable.RippleDrawable

找不到类android.graphics.drawable.RippleDrawable
EN

Stack Overflow用户
提问于 2017-01-21 19:07:53
回答 1查看 5.6K关注 0票数 9

Android应用程序意外关闭,并在log-cat.中出现以下错误

代码语言:javascript
复制
01-22 00:33:58.470 8193-8193/? E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
01-22 00:34:00.010 1173-1173/? E/MyTag: updateClock : 12:34
01-22 00:34:00.015 1173-1173/? E/MyTag: updateClock : 12:34 AM
01-22 00:34:00.051 1173-1173/? E/MyTag: updateClock : 12:34 AM
01-22 00:34:00.080 1432-1432/? E/ActionIcon: time changed: time = 20170122T003400Asia/Calcutta(0,21,19800,0,1485025440)
01-22 00:34:00.086 8210-8210/? E/Zygote: Zygote:  error closing descriptor
                                         libcore.io.ErrnoException: close failed: EBADF (Bad file number)
                                             at libcore.io.Posix.close(Native Method)
                                             at libcore.io.BlockGuardOs.close(BlockGuardOs.java:75)
                                             at com.android.internal.os.ZygoteInit.closeServerSocket(ZygoteInit.java:221)
                                             at com.android.internal.os.ZygoteConnection.handleChildProc(ZygoteConnection.java:879)
                                             at com.android.internal.os.ZygoteConnection.runOnce(ZygoteConnection.java:242)
                                             at com.android.internal.os.ZygoteInit.runSelectLoop(ZygoteInit.java:713)
                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:649)
                                             at dalvik.system.NativeStart.main(Native Method)
EN

回答 1

Stack Overflow用户

发布于 2017-11-15 09:34:39

对我来说,问题是color-selector可绘制,我将其用于ImageViewtint值。崩溃发生在API 19上(我假设它发生在所有设备API <21上)。

有问题的代码

代码语言:javascript
复制
<ImageView
    android:id="@+id/icon"
    android:layout_width="24dp"
    android:layout_height="24dp"
    android:layout_gravity="center"
    android:src="@drawable/ic_music_note_white_24dp"
    android:tint="@color/color_bottom_navigation_item" />

color_bottom_navigation_item.xml

代码语言:javascript
复制
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:color="#00CCF0" android:state_selected="true" />
    <item android:color="#75848C" />
</selector>

解决方案

从XML中删除android:tint属性,并按如下方式编程设置它:

代码语言:javascript
复制
ImageView icon = findViewById(R.id.icon);
ColorStateList tint = getResources().getColorStateList(R.color.color_bottom_navigation_item);

Drawable drawable = ContextCompat.getDrawable(getContext(), R.drawable.ic_music_note_white_24dp);
drawable = DrawableCompat.wrap(drawable).mutate();
DrawableCompat.setTintList(drawable, tint);
icon.setImageDrawable(drawable);
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41783333

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档