I have a custom ButtonRenderer for Android and I want to change the color of the Image that I use for the button.
This is my ButtonRenderer:
public class VolosBaseButtonRenderer : Xamarin.Forms.Platform.Android.AppCompat.ButtonRenderer {
public VolosBaseButtonRenderer(Context context) : base(context) { }
protected override void OnElementChanged(ElementChangedEventArgs<Button> e) {
base.OnElementChanged(e);
// What I must do here for change the Image color????
}
protected override AppCompatButton CreateNativeControl() {
var context = new ContextThemeWrapper(Context, Resource.Style.Widget_AppCompat_Button_Borderless);
var button = new AppCompatButton(context, null, Resource.Style.Widget_AppCompat_Button_Borderless);
return button;
}
}
I tried these methods but none worked:
Control.Background.SetColorFilter(global::Android.Graphics.Color.Blue, global::Android.Graphics.PorterDuff.Mode.SrcIn);
Control.Background.SetTint(Color.Red.ToAndroid());
If it's possible I can apply a style at the button (but I don't know how to do it).
Any methods will be fine.
Thank you!