Hello,
Welcome to our Microsoft Q&A platform!
For this function, try to create a xml file in the Resources/drawable directory to define the button style. Then consume the style for the button in layout.xml.
Check the code:
// Resources/drawable/button_style.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/android_pressed"
android:state_pressed="true" />
<item android:drawable="@drawable/android_focused"
android:state_focused="true" />
<item android:drawable="@drawable/android_normal" />
</selector>
//custom the style for the button in page_layout.xaml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout ...>
...
<Button
android:id="@+id/btn1"
android:text="button1"
android:background="@drawable/android_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
Related tutorial: https://learn.microsoft.com/en-us/xamarin/android/user-interface/controls/buttons/custom-button
Best Regards,
Jarvan Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.