2016-05-14 113 views
0

我在我的RecyclerView中添加了一個FastScroller,並使用了「Bubble」--Drawable。Drawable not working on API 19

如果我測試的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 ... 產生的原因:機器人.view.InflateException:二進制XML文件行#15: 錯誤的類at.guger.fastscro ll.FastScroller

...產生的原因:java.lang.reflect.InvocationTargetException

...產生的原因:android.view.InflateException:二進制XML文件6號線:錯誤充氣類at.guger。 fastscroll.FastScrollBubble

... 造成的:java.lang.reflect.InvocationTargetException

... 產生的原因:android.content.res.Resources $ NotFoundException:文件RES /繪製/ bubble.xml來自可繪製資源ID#0x7f02004b

在android.content.res.Resources.loadDrawable(Resources.java:3457)

在android.content.res.TypedArray.getDrawable(TypedArray.java:602)

在android.view。查看。(View.java:3767)

在android.view.ViewGroup。(ViewGroup.java:481)

在android.widget.FrameLayout。(FrameLayout.java:101)

在android.widget.FrameLayout。(FrameLayout.java:9 7)

在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> 

我的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" /> 

My Folder-Structur E:

+0

沒有我的xml文件在默認的可繪製文件夾中,就像你可以看到的 –

+0

我認爲有一個標籤是不兼容的或者是... –

+0

你正在使用第三方庫,你應該打開一個問題作者GitHub提供了關於如何重現問題的場景和一些信息。 – Leonardo

回答

2

你的問題是?attr/在使用你的繪製

<solid android:color="?attr/colorAccent" /> 

這只是從棒棒糖支持了。因此,對於以下所有版本,您需要直接將顏色定義爲顏色資源。

<solid android:color="@color/colorAccent" /> 

有關更多詳細信息,請參閱How to reference style attributes from a drawable?

+0

哦,謝謝!我很害怕我必須重建整個fastscroller,但這很容易:D –