我在我的RecyclerView中添加了一个RecyclerView,并使用了一个“气泡”-Drawable。
如果我在API 21上测试我的应用程序,它可以工作,但是如果我在API 19上测试它,它会崩溃:
ComponentInfo{at.guger.musixs/at.guger.musixs.ui.MainActivity}::无法启动活动java.lang.RuntimeException android.view.InflateException:二进制XML文件行#15:错误充气类at.guger.fastscroll.FastScroller .由: android.view.InflateException:二进制XML文件行#15:错误充气类at.guger.fastscroll.FastScroller引起 ..。由: java.lang.reflect.InvocationTargetException引起 ..。由: android.view.InflateException:二进制XML文件行#6:错误充气类at.guger.fastscroll.FastScrollBubble引起 ..。由: java.lang.reflect.InvocationTargetException引起 ..。从可绘制资源ID #0x7f02004b引发: android.content.res.Resources$NotFoundException:文件res/ drawable /冒泡File 在android.content.res.Resources.loadDrawable(Resources.java:3457) 在android.content.res.TypedArray.getDrawable(TypedArray.java:602) 在android.view.View.(View.java:3767) 在android.view.ViewGroup.(ViewGroup.java:481) 在android.widget.FrameLayout.(FrameLayout.java:101) 在android.widget.FrameLayout.(FrameLayout.java:97) 在at.guger.fastscroll.FastScrollBubble.(FastScrollBubble.java:0) . 38
我的泡泡-XML-文件:
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:topLeftRadius="@dimen/bubble_corner_radius"
android:topRightRadius="@dimen/bubble_corner_radius"
android:bottomLeftRadius="@dimen/bubble_corner_radius"
android:bottomRightRadius="0dp" />
<solid android:color="?attr/colorAccent" />
<size
android:height="@dimen/bubble_size"
android:width="@dimen/bubble_size" />
</shape>我的飞轮-气泡-布局:
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/fastscroll_bubble"
android:layout_width="64dp"
android:layout_height="64dp"
android:background="@drawable/bubble"
android:gravity="center"
android:textSize="36sp"
tools:text="A"
tools:visibility="visible" />我的文件夹-结构:

发布于 2016-05-14 20:56:47
您的问题是?attr/在绘图中的用法。
<solid android:color="?attr/colorAccent" />这只是来自Lollipop的支持。因此,对于下面的所有版本,您需要将颜色直接定义为颜色资源。
<solid android:color="@color/colorAccent" />有关更多详细信息,请参见How to reference style attributes from a drawable?。
https://stackoverflow.com/questions/37231595
复制相似问题