You can use the property BorderRadius
to create a button with rounded corners:
Following documentation of Xamarin:
<Button Text="BlueButton"
BorderColor="Blue"
BorderRadius = "5"
BorderWidth = "2"/>
In case you are having problems for the rounded button on Android da para você fazer
a custom render.
[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 that you are using in your SetBackgroundResource
for ex. CustomButtonBackground.axml
, thus difinindo 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: I did the translation of that Soeng response
I tried to use this property but it has no effect on my button. I tried various values, I took other properties to see if any could influence the other, but no.
– Henrique Oliveira
not working only on Android, or at all?
– andrepaulo
Only on Android because of Formsappcompact, I saw this answer too, only how do I call this button in Xamarin.Forms? If you answer this I put as resolved. Thanks for the help
– Henrique Oliveira