Skip to content

Instantly share code, notes, and snippets.

@lethargicpanda
Forked from MohammadAG/gist:3503e08deac416a3b71a
Last active August 29, 2015 14:06
Show Gist options
  • Save lethargicpanda/3cd02638b3b6326ee949 to your computer and use it in GitHub Desktop.
Save lethargicpanda/3cd02638b3b6326ee949 to your computer and use it in GitHub Desktop.
// To instantiate a RippleDrawable:
// new RippleDrawable(null, null), the default constructor isn't public.
// Unfortunately, this has no colors set, so the app will crash, here's another way
int[] attrs = new int[] { android.R.attr.selectableItemBackground};
TypedArray array = getContext().obtainStyledAttributes(attrs);
Drawable drawableFromTheme = array.getDrawable(0);
array.recycle();
setBackground(drawableFromTheme);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment