2

I am using a solution from here to make a gradient background splash screen for my application: how to get android gradient center light effect?

I'm using the solution posted by Vadym:

<item >
   <shape xmlns:android="http://schemas.android.com/apk/res/android"
   android:shape="rectangle">
    <gradient
        android:startColor="@android:color/transparent"
        android:endColor="@android:color/black"
        android:centerX="50%"
        android:centerY="50%"
        android:gradientRadius="100%"
        android:type="radial"/>
    </shape>
</item>

Unfortunately, this is causing the whole phone to reboot boot ONLY on Android 5.0! Not 5.1 or 4.4 or 6.0 or 7.0 What's happening there? I cannot even comment Vadyms solution because I still haven't enough reputation. Can somebody add a warning in a comment?

Logcat says:

08-10 09:50:57.395 22267-22292/system_process E/AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: android.display
                                                            java.lang.IllegalArgumentException: radius must be > 0
                                                                at android.graphics.RadialGradient.<init>(RadialGradient.java:57)
                                                                at android.graphics.drawable.GradientDrawable.ensureValidRect(GradientDrawable.java:938)
                                                                at android.graphics.drawable.GradientDrawable.draw(GradientDrawable.java:509)
                                                                at android.graphics.drawable.LayerDrawable.draw(LayerDrawable.java:537)
                                                                at android.view.View.drawBackground(View.java:15352)
                                                                at android.view.View.draw(View.java:15105)
                                                                at android.widget.FrameLayout.draw(FrameLayout.java:592)
                                                                at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2606)
                                                                at android.view.ViewRootImpl.drawSoftware(ViewRootImpl.java:2613)
                                                                at android.view.ViewRootImpl.draw(ViewRootImpl.java:2526)
                                                                at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2337)
                                                                at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1968)
                                                                at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1054)
                                                                at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5786)
                                                                at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
                                                                at android.view.Choreographer.doCallbacks(Choreographer.java:580)
                                                                at android.view.Choreographer.doFrame(Choreographer.java:550)
                                                                at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
                                                                at android.os.Handler.handleCallback(Handler.java:739)
                                                                at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                at android.os.Looper.loop(Looper.java:135)
                                                                at android.os.HandlerThread.run(HandlerThread.java:61)
                                                                at com.android.server.ServiceThread.run(ServiceThread.java:46)
Vishal Vaishnav
  • 3,346
  • 3
  • 26
  • 57
computerjulian
  • 173
  • 1
  • 11

2 Answers2

2

On API<21 gradientRadius doesn't accept % value. To fix the issue, you can use the %p (https://developer.android.com/reference/android/graphics/drawable/GradientDrawable.html#attr_android:gradientRadius)

android:gradientRadius="100%p"
0

Try this;

System.runFinalization();
Runtime.getRuntime().gc();
System.gc();
Vishal Vaishnav
  • 3,346
  • 3
  • 26
  • 57