void SetImageViewTintColor(ImageView image, Forms.Color color) { if (color == Forms.Color.Default) { image.ClearColorFilter(); } image.SetColorFilter(new PorterDuffColorFilter(color.ToAndroid(), PorterDuff.Mode.SrcIn ?? throw new NullReferenceException())); }
void SetImageViewTintColor(ImageView image, Forms.Color color) { if (color == Forms.Color.Default) { image.ClearColorFilter(); } image.SetColorFilter(new PorterDuffColorFilter(color.ToAndroid(), PorterDuff.Mode.SrcIn)); }
void SetButtonTintColor(Button button, Forms.Color color) { var drawables = button.GetCompoundDrawables().Where(d => d != null); if (color == Forms.Color.Default) { foreach (var img in drawables) { img.ClearColorFilter(); } } foreach (var img in drawables) { img.SetTint(color.ToAndroid()); } }