Skip to content

Instantly share code, notes, and snippets.

@kiwiandroiddev
Created October 8, 2015 21:48
Show Gist options
  • Select an option

  • Save kiwiandroiddev/dd972eee8db7a2d845ef to your computer and use it in GitHub Desktop.

Select an option

Save kiwiandroiddev/dd972eee8db7a2d845ef to your computer and use it in GitHub Desktop.
Resolves a custom Android attribute to a resource ID for an Activity's theme.
public class ThemeUtils {
public static int getResourceIdForAttribute(@AttrRes int attrId, Activity activity) {
TypedValue outValue = new TypedValue();
activity.getTheme().resolveAttribute(attrId, outValue, true);
return outValue.resourceId;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment