Created
January 17, 2014 09:01
-
-
Save Cheesebaron/8470364 to your computer and use it in GitHub Desktop.
IMenuItem disabled color change.
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
public static class DroidExtensions | |
{ | |
public static IMenuItem SetEnabled(this IMenuItem item, bool enabled, Context context, int iconId) | |
{ | |
return item.SetEnabled(enabled, context, iconId, Color.Gray); | |
} | |
public static IMenuItem SetEnabled(this IMenuItem item, bool enabled, Context context, int iconId, Color disabledColor) | |
{ | |
var resIcon = context.Resources.GetDrawable(iconId); | |
if (!enabled) | |
resIcon.Mutate().SetColorFilter(disabledColor, PorterDuff.Mode.SrcIn); | |
item.SetEnabled(enabled); | |
item.SetIcon(resIcon); | |
return item; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment