aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/ca/allanwang/kau/views/SimpleRippleDrawable.kt
blob: df842f658ea39cb07f240ff3087edc01289512e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package ca.allanwang.kau.views

import android.content.res.ColorStateList
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.RippleDrawable
import android.support.annotation.ColorInt
import ca.allanwang.kau.utils.adjustAlpha

/**
 * Created by Allan Wang on 2017-06-24.
 *
 * Tries to mimic a standard ripple, given the foreground and background colors
 */
fun createSimpleRippleDrawable(@ColorInt foregroundColor: Int, @ColorInt backgroundColor: Int): RippleDrawable {
    val states = ColorStateList(arrayOf(intArrayOf()), intArrayOf(foregroundColor))
    val content = ColorDrawable(backgroundColor)
    val mask = ColorDrawable(foregroundColor.adjustAlpha(0.16f))
    return RippleDrawable(states, content, mask)
}