And Batu And Batu - 4 months ago 31
Android Question

Custom button style on android

I am creating a custom button using the following link. I followed every step.
https://androidcookbook.com/Recipe.seam?recipeId=3307

Then I created a button the following way :

<Button
android:id="@+id/btnButton1"
android:layout_width="95dp"
android:layout_height="wrap_content"
android:buttonStyle="@style/button"
android:text="CREATE"
android:onClick="createButtonClickHandler"/>


But I see my button has default style. I expected my button has this new fancy custom style.

Answer

Don't use buttonStyle , use just style:

   <Button
    android:id="@+id/btnButton1"
    android:layout_width="95dp"
    android:layout_height="wrap_content"
    android:style="@style/button"
    android:text="CREATE"
    android:onClick="createButtonClickHandler"/>

Reference : https://developer.android.com/guide/topics/ui/themes.html