Skip to content

Instantly share code, notes, and snippets.

@ademar111190
Created April 1, 2015 22:36
Show Gist options
  • Save ademar111190/eca5526503e5a639cc5e to your computer and use it in GitHub Desktop.
Save ademar111190/eca5526503e5a639cc5e to your computer and use it in GitHub Desktop.
Just an way to create ripple drawables in java code
// 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