Eddie Carter
Eddie Carter

Reputation: 1

Why is the button border not disappearing when using a border radius of 0 in xamarin forms (Xaml)?

I am looking to make the button border to disappear when using xaml. I have tried to make the border radius = 0 and tried to make the background colour transparent. If you know the solution with XAML code that would be useful. Thank you.

Xamarin.Forms Version:2.3.4.247.

Visual result

Expected Result

XAML:

<Button Image="nav_menu.png"
        VerticalOptions="Center" 
        HorizontalOptions="End" 
        BackgroundColor="Transparent" 
        BorderColor="Transparent" 
        BorderRadius="0"/> 

Upvotes: 0

Views: 350

Answers (1)

Timothy James
Timothy James

Reputation: 1102

Oops! Just saw the image you had in your OP.

Ah, so what you're experiencing is not actually a border but a shadow. This is easily fixed by setting the style. Directions taken from this forum post.

In your Droid project, go to Resources/values/style.xml, set your state list animator to null. It should look something like this:

<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <style name="AppTheme" parent="AppTheme.Base">
    </style>
    <style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:buttonStyle">@style/NoShadowButton</item>
    </style>
    <style name="NoShadowButton" parent="android:style/Widget.Button">
        <item name="android:stateListAnimator">@null</item>
    </style>
</resources>

Let me know if this doesn't work for you.

Upvotes: 1

Related Questions