daimajia / NumberProgressBar

A beautiful, slim Android ProgressBar.
MIT License
6.07k stars 1.4k forks source link

Android Studio 3.0 - InflateException #55

Open CarstenHouweling opened 7 years ago

CarstenHouweling commented 7 years ago

I recently updated my working project to Android Studio 3 with all the latest repository versions and i ran into an issue with your library:

android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class com.daimajia.numberprogressbar.NumberProgressBar Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class com.daimajia.numberprogressbar.NumberProgressBar

Caused by: java.lang.UnsupportedOperationException: Can't convert value at index 2 to color: type=0x5 at android.content.res.TypedArray.getColor(TypedArray.java:473) at com.daimajia.numberprogressbar.NumberProgressBar.<init>(NumberProgressBar.java:185)

Line 185: mUnreachedBarColor = attributes.getColor(R.styleable.NumberProgressBar_progress_unreached_color,default_unreached_color);

I use your library as followed:

<com.daimajia.numberprogressbar.NumberProgressBar
                android:id="@+id/progress"
                style="@style/NumberProgressBar_Custom"
                android:layout_alignParentBottom="true"
                android:visibility="gone" />
<style name="NumberProgressBar_Custom" parent="NumberProgressBar_Default">
        <item name="progress_reached_color">@color/colorPrimary</item>
        <item name="progress_reached_bar_height">5dp</item>
        <item name="progress_unreached_color">@android:color/transparent</item>
        <item name="progress_text_color">@color/colorPrimary</item>
        <item name="progress_text_size">5sp</item>
    </style>

Removing the progress_unreached_color item does not work. Changing the unreached color to @color/white for example does not work.


After further investigation i notice i cannot add two of your styling items: progress_text_color & progress_reached_bar_height

When i set the other styling parameters, it works fine:

<com.daimajia.numberprogressbar.NumberProgressBar
                android:id="@+id/progress"
                android:layout_height="wrap_content"
                android:layout_width="match_parent"
                bar:max="100"
                bar:progress="0"
                bar:progress_unreached_color="#ff0000" (@android:color/transparent also works)
                bar:progress_reached_color="#00ff00" (@color/colorPrimary also works)
                bar:progress_text_size="5sp"
                bar:progress_unreached_bar_height="0.75dp"
                android:layout_alignParentBottom="true"
                android:visibility="gone" />
Yexiangxu commented 6 years ago

me too, How to solve this problem

RockyLin commented 6 years ago

Actually, they've already fixed this bug in version 1.4, even though, you have to change a few attribute names.