Create a view renderer for your custom button. Then replace it with your native layout:
[assembly: ExportRenderer(typeof(CustomButton), typeof(CustomButtonRenderer))]
namespace App.Droid
{
public class CustomButtonRenderer : ViewRenderer<CustomButton, Android.Views.View>
{
Context _context;
public CustomButtonRenderer(Context context) : base(context)
{
_context = context;
}
protected override void OnElementChanged(ElementChangedEventArgs<CustomButton> e)
{
base.OnElementChanged(e);
if (Control == null)
{
SetNativeControl(getView());
}
}
Android.Views.View getView()
{
return LayoutInflater.From(_context).Inflate(Resource.Layout.custom_layout, null);
}
}
}
At last you can consume the custom control in XAML like:
<StackLayout>
<local:CustomButton />
</StackLayout>