I am using a customized thumb with a Seekbar. The thumb is a white circle with a shadow behind created using a gradient. It works as expected in most cases, but with some devices i get the error java.lang.IllegalArgumentException: radius must be > 0 when the layout is loaded :
java.lang.IllegalArgumentException: radius must be > 0
at android.graphics.RadialGradient.<init>(RadialGradient.java:53)
at android.graphics.drawable.GradientDrawable.ensureValidRect(GradientDrawable.java:757)
at android.graphics.drawable.GradientDrawable.draw(GradientDrawable.java:426)
at android.graphics.drawable.LayerDrawable.draw(LayerDrawable.java:349)
at android.widget.AbsSeekBar.onDraw(AbsSeekBar.java:337)
at android.view.View.draw(View.java:14757)
at android.view.View.getDisplayList(View.java:13617)
at android.view.View.getDisplayList(View.java:13664)
at android.view.View.draw(View.java:14459)
at android.view.ViewGroup.drawChild(ViewGroup.java:3273)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3091)
at android.view.View.draw(View.java:14768)
at android.view.View.getDisplayList(View.java:13617)
at android.view.View.getDisplayList(View.java:13664)
at android.view.View.draw(View.java:14459)
at android.view.ViewGroup.drawChild(ViewGroup.java:3273)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3091)
at android.view.View.getDisplayList(View.java:13609)
at android.view.View.getDisplayList(View.java:13664)
at android.view.View.draw(View.java:14459)
[...]
This only seems to happen on a some rare devices, and since flurry cannot report what they are (Unidentified), I assume they are rooted.
Below the xml used to create the thumb :
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/lockscreen_thumb_shadow"/>
<item android:drawable="@drawable/lockscreen_thumb_round"
android:bottom="10dp"
android:top="10dp"
android:left="10dp"
android:right="10dp"/>
</layer-list>
lockcreen_thumb_shadow :
<?xml version="1.0" encoding="utf-8"?>
<shape
android:shape="oval"
xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:type="radial" android:gradientRadius="35dp"
android:endColor="#14009FE8"
android:centerColor="#96009FE8"
android:startColor="#009FE8"
android:innerRadius="20dp"
/>
<size android:width="70dp" android:height="70dp"/>
</shape>
lockscreen_thumb_round :
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<size android:height="40dp"
android:width="40dp" />
<solid android:color="@android:color/white" />
</shape>
I had this problem when i used gradient and found out that lollipop 5.0, has a problem with % in gradientRadius value.
I had this line:
android:gradientRadius="120%"
and changed it to this:
android:gradientRadius="120%p"
And the problem was solved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With