Skip to content

Instantly share code, notes, and snippets.

View lethargicpanda's full-sized avatar

Thomas Ezan lethargicpanda

View GitHub Profile
// 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);