ZieIony / Carbon

Material Design implementation for Android 4.0+. Shadows, ripples, vectors, fonts, animations, widgets, rounded corners and more.

Home Page:https://androidreclib.wordpress.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ShadowRenderer.drawCornerShadow - IllegalArgumentException: radius must be > 0

ZieIony opened this issue · comments

For the moment, it's my failure that I removed the Theme that in style.xml, so when I added it back, Carbon works well, but below exception occured :

java.lang.IllegalArgumentException: radius must be > 0
    at android.graphics.RadialGradient.<init>(RadialGradient.java:59)
    at carbon.shadow.ShadowRenderer.drawCornerShadow(ShadowRenderer.java:158)
    at carbon.shadow.ShapePath$ArcShadowOperation.draw(ShapePath.java:289)
    at carbon.shadow.ShapePath$1.draw(ShapePath.java:179)
    at carbon.shadow.ShapePath$ShadowCompatOperation.draw(ShapePath.java:229)
    at carbon.shadow.MaterialShapeDrawable.drawCompatShadow(MaterialShapeDrawable.java:383)
    at carbon.shadow.MaterialShapeDrawable.draw(MaterialShapeDrawable.java:344)
    at carbon.widget.ImageView.drawShadow(ImageView.java:619)
    at carbon.widget.ConstraintLayout.drawChild(ConstraintLayout.java:313)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3513)
    at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:2023)
    at carbon.widget.ConstraintLayout.dispatchDrawInternal(ConstraintLayout.java:290)
    at carbon.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:282)
    at android.view.View.draw(View.java:17308)
    at carbon.widget.ConstraintLayout.drawInternal(ConstraintLayout.java:420)
    at carbon.widget.ConstraintLayout.draw(ConstraintLayout.java:482)
    at android.view.View.updateDisplayListIfDirty(View.java:16282)
    at android.view.View.draw(View.java:17066)
    at android.view.ViewGroup.drawChild(ViewGroup.java:3727)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3513)
    at android.view.View.updateDisplayListIfDirty(View.java:16277)
    at android.view.View.draw(View.java:17066)
    at android.view.ViewGroup.drawChild(ViewGroup.java:3727)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3513)
    at android.view.View.updateDisplayListIfDirty(View.java:16277)
    at android.view.View.draw(View.java:17066)
    at android.view.ViewGroup.drawChild(ViewGroup.java:3727)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3513)
    at android.view.View.draw(View.java:17308)
    at com.android.internal.policy.DecorView.draw(DecorView.java:786)
    at android.view.View.updateDisplayListIfDirty(View.java:16282)
    at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:661)
    at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:667)
    at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:775)
    at android.view.ViewRootImpl.draw(ViewRootImpl.java:2829)
    at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2637)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2239)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1270)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6464)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:888)
    at android.view.Choreographer.doCallbacks(Choreographer.java:700)
    at android.view.Choreographer.doFrame(Choreographer.java:635)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:874)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6405)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1003)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:893)

Originally posted by @codingCavalier in #387 (comment)

Is there has any problem?

PathArcOperation pathArcOperation = new PathArcOperation(endX, endY, endX, endY);
pathArcOperation.startAngle = currentShadowAngle;
pathArcOperation.sweepAngle = shadowSweep;
shadowCompatOperations.add(new ArcShadowOperation(pathArcOperation));
currentShadowAngle = nextShadowAngle;

Originally posted by @codingCavalier in #387 (comment)

Could you please provide more information about your issue? This error is most likely related to the size of a view in your layout or its shadow.

As a side note - MaterialShapeDrawable and other shadow-drawing code is borrowed from Material Components, so there may already be an answer for this issue on SO or Google's issue tracker.

I tried to use ConstraintLayout with a bunch of different options and I'm unable to reproduce your issue. ConstraintLayout uses the same drawing code as all other layouts and views and the shadow drawing code is provided by Google.

If you wish me to help you, please provide minimal working example of the faulty code/xml/configuration. Ideally please share the project on GitHub - the issue can be not in the layout, but somewhere else.

I don't usually do that. All issues related to Carbon should be discussed here, so others can contribute and benefit from these discussions.