Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

border radius button don't work on android

I use Xamarin.Forms, I try set BorderRadius = 10 or BorderRadius = Device.OnPlatform<int>(iOS: 0, Android: 10, WinPhone: 10) . On UWP it's ok (both ways) but on android BorderRadius in not apply

like image 386
Dmitrii Kurylev Avatar asked Jun 11 '26 20:06

Dmitrii Kurylev


1 Answers

Button I want change BorderRadius from Button

Problem is with the ButtonRenderer of Xamarin Forms for Android. There are two kinds of ButtonRenderers for Android:

ButtonRenderer under Xamarin.Forms.Platform.Android namespace and ButtonRenderer under Xamarin.Forms.Platfrom.Android.AppCompat namespace.

By default in Xamarin.Forms, it will use the ButtonRenderer under the Xamarin.Forms.Platfrom.Android.AppCompat namespace to render the button, but this renderer doesn't create a border for Button, so the BorderRadius properties doesn't work for the buttons which are rendered with this renderer.

To solve this issue, you can create your own custom button with Custom Renderer, and use the ButtonRenderer under Xamarin.Forms.Platform.Android namespace for rendering.

For creating a Custom renderer for your Button, you can refer to this discussion.

like image 61
Grace Feng Avatar answered Jun 13 '26 11:06

Grace Feng



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!