Android button pressed style

MJoehlMJoehl USMember ✭✭

Hi there

I have two buttons in my Xamarin.Forms page (XAML). One button with a style (from App.xaml) and the other one without a style.

The button without a style shows up in gray and changes the style when I'm pressing it.
But the one with the style do not have this behaviour (don't chagnes the style while i'm pressing it).

My theme for the android project:

<style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="windowActionModeOverlay">true</item>
    <item name="android:displayOptions">showHome|homeAsUp|showTitle</item>
    <item name="displayOptions">showHome|homeAsUp|showTitle</item>
    <item name="android:icon">@android:color/transparent</item>


<Button Text="With style" Style="{StaticResource DefaultButton}" />
<Button Text="Without style" />

Then the style for the button (located in the App.xaml)

<Style x:Key="DefaultButton" TargetType="Button">
        <Setter Property="HorizontalOptions" Value="Fill" />
        <Setter Property="TextColor" Value="Black" />
        <Setter Property="BackgroundColor" Value="Green" />
        <Setter Property="BorderColor" Value="Red" />
        <Setter Property="FontSize">
        <OnPlatform x:TypeArguments="x:Double" iOS="16" Android="16" WinPhone="20" />

How can I have a button with a style and a pressed-style? Thanks in advance


  • CaseCase USMember ✭✭✭

    Did you figure this issue out? I'm facing the same problem. I'm used to developing in Android Studio where I can define a set of styles for the button states.

    Now I would like to do the same thing in a cross-platform using the Application Resources.

Sign In or Register to comment.