File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
lib/java/com/google/android/material/shadow Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -149,16 +149,21 @@ public void drawCornerShadow(
149149 cornerColors [3 ] = shadowEndColor ;
150150 }
151151
152- float startRatio = 1f - (elevation / (bounds .width () / 2f ));
152+ float radius = bounds .width () / 2f ;
153+ // The shadow is not big enough to draw.
154+ if (radius <= 0 ) {
155+ return ;
156+ }
157+
158+ float startRatio = 1f - (elevation / radius );
153159 float midRatio = startRatio + ((1f - startRatio ) / 2f );
154160 cornerPositions [1 ] = startRatio ;
155161 cornerPositions [2 ] = midRatio ;
156-
157162 cornerShadowPaint .setShader (
158163 new RadialGradient (
159164 bounds .centerX (),
160165 bounds .centerY (),
161- bounds . width () / 2 ,
166+ radius ,
162167 cornerColors ,
163168 cornerPositions ,
164169 Shader .TileMode .CLAMP ));
You can’t perform that action at this time.
0 commit comments