am 6e85abd4: Merge "Default gradient radius to %p when no intrinsic width or height set" into lmp-mr1-dev
* commit '6e85abd45b890bf583346a0935d1f24a789dc88b': Default gradient radius to %p when no intrinsic width or height set
This commit is contained in:
@@ -943,7 +943,11 @@ public class GradientDrawable extends Drawable {
|
|||||||
|
|
||||||
float radius = st.mGradientRadius;
|
float radius = st.mGradientRadius;
|
||||||
if (st.mGradientRadiusType == RADIUS_TYPE_FRACTION) {
|
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) {
|
} else if (st.mGradientRadiusType == RADIUS_TYPE_FRACTION_PARENT) {
|
||||||
radius *= Math.min(r.width(), r.height());
|
radius *= Math.min(r.width(), r.height());
|
||||||
}
|
}
|
||||||
@@ -954,9 +958,9 @@ public class GradientDrawable extends Drawable {
|
|||||||
|
|
||||||
mGradientRadius = radius;
|
mGradientRadius = radius;
|
||||||
|
|
||||||
if (radius == 0) {
|
if (radius <= 0) {
|
||||||
// We can't have a shader with zero radius, so let's
|
// We can't have a shader with non-positive radius, so
|
||||||
// have a very, very small radius.
|
// let's have a very, very small radius.
|
||||||
radius = 0.001f;
|
radius = 0.001f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user