You can use the BorderRadius
property to create a button with rounded corners:
Following the Xamarin documentation :
<Button Text="BlueButton"
BorderColor="Blue"
BorderRadius = "5"
BorderWidth = "2"/>
If you're having problems with the round button on Android, you can do it
a custom rendering.
[assembly: ExportRenderer(typeof(CustomButton), typeof(CustomButtonRenderer))]
namespace AppCompatRender.Droid
{
public class CustomButtonRenderer : Xamarin.Forms.Platform.Android.AppCompat.ButtonRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
{
base.OnElementChanged(e);
if (e.OldElement == null)
{
Control.SetBackgroundResource(Resource.Drawable.CustomButtonBackground);
}
}
}
}
Add a new Resources/Drawable
that has the same name you're using in your SetBackgroundResource
for ex. CustomButtonBackground.axml
, thus defining the corners of the rectangle as 10dp
:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="10dp" />
</shape>
Note:Ididthe translation of this SOEng response