diff --git a/graphics/java/android/graphics/drawable/GradientDrawable.java b/graphics/java/android/graphics/drawable/GradientDrawable.java index ddbbaf17f2a59..91a2bc18b6ccd 100644 --- a/graphics/java/android/graphics/drawable/GradientDrawable.java +++ b/graphics/java/android/graphics/drawable/GradientDrawable.java @@ -319,7 +319,16 @@ public class GradientDrawable extends Drawable { } } else { + // since the caller is only giving us 1 value, we will force + // it to be square if the rect is too small in one dimension + // to show it. If we did nothing, Skia would clamp the rad + // independently along each axis, giving us a thin ellips + // if the rect were very wide but not very tall float rad = st.mRadius; + float r = Math.min(mRect.width(), mRect.height()) * 0.5f; + if (rad > r) { + rad = r; + } canvas.drawRoundRect(mRect, rad, rad, mFillPaint); if (haveStroke) { canvas.drawRoundRect(mRect, rad, rad, mStrokePaint);