Hello guys, I need some help to fix an issue here... I need to implement a FAB button to my application, and after some search in the Nuget, I choose from SuaveControls solution... In this package I got 2 problems, the package is deprecated, and the render result (only in Android) is looking like the image attached.
I try different things but nothing happens, the image (icon) isn't applyed to the button and its size doesn't changes...
The render is bellow:
public class FloatingActionButtonRenderer : Xamarin.Forms.Platform.Android.AppCompat.ViewRenderer<FloatingActionButton, FAB>
{
public static void Initialize()
{
}
public FloatingActionButtonRenderer(Context context) : base(context)
{
}
protected override void OnElementChanged(ElementChangedEventArgs<FloatingActionButton> e)
{
base.OnElementChanged(e);
if (e.NewElement == null) return;
var fab = new FAB(Context);
// set the bg
Android.Support.V4.View.ViewCompat.SetBackgroundTintList(fab, ColorStateList.ValueOf(Element.ButtonColor.ToAndroid()));
fab.UseCompatPadding = true;
// set the icon
var elementImage = Element.Image;
var imageFile = elementImage?.File;
if (imageFile != null)
{
fab.SetImageDrawable(Context.GetDrawable(imageFile));
//SetFabImage(imageFile);
}
fab.Click += this.Fab_Click;
SetNativeControl(fab);
}
protected override void OnLayout(bool changed, int l, int t, int r, int b)
{
base.OnLayout(changed, l, t, r, b);
Control.BringToFront();
}
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
var fab = (FAB)Control;
if (e.PropertyName == nameof(Element.ButtonColor))
{
Android.Support.V4.View.ViewCompat.SetBackgroundTintList(fab, ColorStateList.ValueOf(Element.ButtonColor.ToAndroid()));
}
if (e.PropertyName == nameof(Element.Image))
{
var elementImage = Element.Image;
var imageFile = elementImage?.File;
if (imageFile != null)
{
fab.SetImageDrawable(Context.GetDrawable(imageFile));
//SetFabImage(imageFile);
}
}
base.OnElementPropertyChanged(sender, e);
}
private void Fab_Click(object sender, EventArgs e)
{
// proxy the click to the element
((IButtonController)Element).SendClicked();
}
}
Do you have any tip or help to me?
Best regards,
Alex Florindo