Search code examples
c#xamarinxamarin.formscustom-renderer

Gradient as a Buttons BorderColor Xamarin Android?


I am trying to Create a Button with Gradient Border Color in Xamarin Forms, i find the solution below to IOS but I can't find anything for android, can someone help me?

Gradient as a Buttons BorderColor?


Solution

  • You could use the PancakeView which provides border with gradients, and add a touch gesture recognizer:

    <yummy:PancakeView 
        BackgroundColor="#e2e885" 
        BorderGradientStops="{StaticResource Rainbow}" 
        HeightRequest="150" 
        CornerRadius="40,10,40,10" 
        BorderThickness="4" 
        BorderColor="#456287">
        <yummy:PancakeView.GestureRecognizers>
            <TapGestureRecognizer Command="{Binding OnTapCommand}" NumberOfTapsRequired="1" />
        </yummy:PancakeView.GestureRecognizers>
        <Label Text="Button text" HorizontalOptions="Center" VerticalOptions="Center" />
    </yummy:PancakeView>