Last active
December 24, 2018 12:02
-
-
Save dextorer/0af49425900eec37f82f392d52e40d60 to your computer and use it in GitHub Desktop.
ripples_pie_regression_2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun updateButtonView(button: View) { | |
val radius = // ... | |
val color = // ... | |
val contentOuterRadii = floatArrayOf(radius, radius, radius, radius, radius, radius, radius, radius) | |
val buttonShape = RoundRectShape(contentOuterRadii, null, null) | |
if (button.background != null) { | |
val ripple = button.background as RippleDrawable | |
(ripple.getDrawable(0) as ShapeDrawable).apply { // content | |
shape = buttonShape | |
} | |
(ripple.getDrawable(1) as ShapeDrawable).apply { // mask | |
shape = buttonShape | |
} | |
} else { | |
@ColorInt val maskColor = resources.getColor(R.color.white) | |
val maskShapeDrawable = ShapeDrawable(buttonShape).apply { | |
paint.color = maskColor | |
} | |
val contentShapeDrawable = ShapeDrawable(buttonShape).apply { | |
paint.color = color | |
} | |
button.background = RippleDrawable(ColorStateList.valueOf(maskColor), contentShapeDrawable, maskShapeDrawable) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment