Dmitrii Kurylev
Dmitrii Kurylev

Reputation: 437

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

Upvotes: 2

Views: 5623

Answers (2)

Anas Alweish
Anas Alweish

Reputation: 3026

Another solution

Change your renderer constructor like this.

public CustomButtonRenderer(Context context) : base(context)
{

}

Upvotes: 0

Grace Feng
Grace Feng

Reputation: 16652

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.

Upvotes: 10

Related Questions