diff options
author | Alan Viverette <alanv@google.com> | 2014-11-03 18:45:23 -0800 |
---|---|---|
committer | Alan Viverette <alanv@google.com> | 2014-11-03 18:45:23 -0800 |
commit | b4f8a981769e95500ab6c86ab45102dc9c7e53c6 (patch) | |
tree | 2b04d3865d17a94f5eb66b3815211839dd716ea0 /graphics/java | |
parent | 6f7fd0ba50ad15788a1378eb62ec7d8a78983051 (diff) | |
download | frameworks_base-b4f8a981769e95500ab6c86ab45102dc9c7e53c6.zip frameworks_base-b4f8a981769e95500ab6c86ab45102dc9c7e53c6.tar.gz frameworks_base-b4f8a981769e95500ab6c86ab45102dc9c7e53c6.tar.bz2 |
Default gradient radius to %p when no intrinsic width or height set
BUG: 18224018
Change-Id: I05cbe3023d0a5e6813658063d3a3633c6ddd8d96
Diffstat (limited to 'graphics/java')
-rw-r--r-- | graphics/java/android/graphics/drawable/GradientDrawable.java | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/graphics/java/android/graphics/drawable/GradientDrawable.java b/graphics/java/android/graphics/drawable/GradientDrawable.java index 1458238..94c7026 100644 --- a/graphics/java/android/graphics/drawable/GradientDrawable.java +++ b/graphics/java/android/graphics/drawable/GradientDrawable.java @@ -943,7 +943,11 @@ public class GradientDrawable extends Drawable { float radius = st.mGradientRadius; if (st.mGradientRadiusType == RADIUS_TYPE_FRACTION) { - radius *= Math.min(st.mWidth, st.mHeight); + // Fall back to parent width or height if intrinsic + // size is not specified. + final float width = st.mWidth >= 0 ? st.mWidth : r.width(); + final float height = st.mHeight >= 0 ? st.mHeight : r.height(); + radius *= Math.min(width, height); } else if (st.mGradientRadiusType == RADIUS_TYPE_FRACTION_PARENT) { radius *= Math.min(r.width(), r.height()); } @@ -954,9 +958,9 @@ public class GradientDrawable extends Drawable { mGradientRadius = radius; - if (radius == 0) { - // We can't have a shader with zero radius, so let's - // have a very, very small radius. + if (radius <= 0) { + // We can't have a shader with non-positive radius, so + // let's have a very, very small radius. radius = 0.001f; } |