I have the following class in my Droid-Project:
using MyProject.Droid;
using Xamarin.Forms.Platform.Android;
[assembly: Xamarin.Forms.ExportRenderer(typeof(Android.Widget.Button), typeof(ArrowButtonRenderer))]
namespace MyProject.Droid
{
public class ArrowButtonRenderer : Xamarin.Forms.Platform.Android.ButtonRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Button> e)
{
base.OnElementChanged(e);
var btn = this.Control as Android.Widget.Button;
btn.SetBackgroundColor(global::Android.Graphics.Color.Green);
}
}
}
I know, you dont need a custom renderer for changing a button's color, but I just wanna try things out :)
Cheers!
Edit: Here's the code about how I add the button's to the UI:
MyStackLayout.Children.Add(new Button
{
Text = "My Button Text"
});
And some buttons through xaml:
<Button x:Name="btnIdk" Text="something" />
typeof(Android.Widget.Button)to the Xamarin Forms button, sotypeof(Xamarin.Forms.Button)