Setting selected state on a button in Xamarin Android

So you'd like to change the appearance of a button and for it to keep that appearance as long as it has been selected? This will change the appearance of the button to have a 4dp deep border along the bottom side of the bottom as long as it is selected.

In your view, add an on click delegate:

var myButton = (Button)Activity.FindViewById(Resource.Id.myButton);
myButton.Click += delegate
    myButton.Selected = true;

Define your layout and button, setting the background to a drawable defined below:

            android:text="My Button" />

Create an xml file btn_border.xml in drawable:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="">
<item android:drawable="@drawable/btn_border_pressed" android:state_pressed="true" />
<item android:drawable="@drawable/btn_border_pressed" android:state_focused="true" />
<item android:drawable="@drawable/btn_border_pressed" android:state_selected="true" />

Create a second xml file btn_border_pressed.xml in drawable:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="" >
<item android:bottom="0dp" android:left="-4.5dp" android:right="-4.5dp" android:top="-4.5dp">
<shape android:shape="rectangle" >
<stroke android:width="4dp" android:color="@color/selected_red" />

And there you have it. Remember to set "selected" to false when you no longer want the button to hold the selected state.