Skip to content

Instantly share code, notes, and snippets.

@Cheesebaron
Created January 17, 2014 09:01
Show Gist options
  • Save Cheesebaron/8470364 to your computer and use it in GitHub Desktop.
Save Cheesebaron/8470364 to your computer and use it in GitHub Desktop.
IMenuItem disabled color change.
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