Skip to content

Instantly share code, notes, and snippets.

@webserveis
Created October 9, 2016 14:21
Show Gist options
  • Save webserveis/6ddc2d2b09789fb04411d09903796c9c to your computer and use it in GitHub Desktop.
Save webserveis/6ddc2d2b09789fb04411d09903796c9c to your computer and use it in GitHub Desktop.
Get atributes android programallity
private int fetchAccentColor(Activity context) {
TypedValue typedValue = new TypedValue();
TypedArray a = context.obtainStyledAttributes(typedValue.data, new int[]{R.attr.colorAccent});
int color = a.getColor(0, 0);
a.recycle();
return color;
}
private int fetchTextPrimaryColor() {
TypedValue typedValue = new TypedValue();
TypedArray a = obtainStyledAttributes(typedValue.data, new int[]{android.R.attr.textColorPrimary,});
int color = a.getColor(0, 0);
a.recycle();
return color;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment