blob: 30c8eddadc90f24152614a878b12042aff88ca9e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
package ca.allanwang.kau.ui
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)
}
|