Created
April 14, 2017 07:45
-
-
Save g4s8/98c023dad8b2c40060da04a20f77e65d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class StyledContext extends ContextThemeWrapper { | |
@StyleRes | |
private static int themeRes(@NonNull final Resources.Theme theme, @AttrRes final int themeResId) { | |
final TypedValue outValue = new TypedValue(); | |
theme.resolveAttribute(themeResId, outValue, true); | |
return outValue.resourceId; | |
} | |
public StyledContext(final Context ctx, final @AttrRes int themeResId) { | |
super(ctx, themeRes(ctx.getTheme(), themeResId)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment