【发布时间】:2016-09-10 22:12:22
【问题描述】:
我在 RecyclerView 中添加了一个 FastScroller 并使用了“Bubble”-Drawable。
如果我在 API 21 上测试我的应用程序,它可以工作,但如果我在 API 19 上测试它,它会崩溃:
java.lang.RuntimeException:无法启动活动 ComponentInfo{at.guger.musixs/at.guger.musixs.ui.MainActivity}:
android.view.InflateException:二进制 XML 文件第 15 行:错误 膨胀类 at.guger.fastscroll.FastScroller ... 引起:android.view.InflateException:二进制 XML 文件第 15 行: 在.guger.fastscroll.FastScroller 膨胀类时出错
...引起:java.lang.reflect.InvocationTargetException
... 原因:android.view.InflateException: Binary XML file line #6: Error inflating class at.guger.fastscroll.FastScrollBubble
... 引起:java.lang.reflect.InvocationTargetException
... 原因:android.content.res.Resources$NotFoundException:文件 res/drawable/bubble.xml 来自可绘制资源 ID #0x7f02004b
在 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
我的 Bubble-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>
我的 FastScroll-Bubble-Layout:
<?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" />
我的文件夹结构:
【问题讨论】:
-
没有我的xml文件在默认的drawable文件夹中,就像你看到的那样
-
我认为是标签不兼容之类的...
-
你正在使用第三方库,你应该在作者 GitHub 上打开一个问题,提供场景和一些关于如何重现问题的信息。
-
图书馆是我自己做的;)
-
哦,对不起!它是开源的吗?检查一些代码会更容易......
标签: java android xml android-layout