Skip to content

Instantly share code, notes, and snippets.

@alorma
Created February 25, 2015 13:59
Show Gist options
  • Save alorma/5b62121a8ff9b87ffb9f to your computer and use it in GitHub Desktop.
Save alorma/5b62121a8ff9b87ffb9f to your computer and use it in GitHub Desktop.
public static Drawable getDefaultButtonBackground(Context context) {
int[] attrsButtonStyle = {android.R.attr.buttonStyle};
TypedArray taButtonStyle = context.getTheme().obtainStyledAttributes(attrsButtonStyle);
int buttonStyle = taButtonStyle.getResourceId(0, 0);
taButtonStyle.recycle();
int[] attrs = {android.R.attr.background};
TypedArray ta = context.getTheme().obtainStyledAttributes(buttonStyle, attrs);
Drawable background = ta.getDrawable(0);
ta.recycle();
return background;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment