Created
April 1, 2015 22:36
-
-
Save ademar111190/eca5526503e5a639cc5e to your computer and use it in GitHub Desktop.
Just an way to create ripple drawables in java code
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
// TODO test if works | |
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | |
int[][] states = new int[][] { new int[] { android.R.attr.state_pressed } }; | |
int[] colors = new int[] { color }; | |
ColorStateList colorStateList = new ColorStateList(states, colors); | |
RippleDrawable rippleDrawable = new RippleDrawable(colorStateList, null, null); | |
view.setBackground(rippleDrawable); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment