Comment définir le Style d'un bouton dans Android?

J'ai défini ci-dessous les fichiers dans le dossier res.

styles_apptheme.xml

<?xml version="1.0" encoding="utf-8"?>

<!-- Generated with http://android-holo-colors.com -->
<resources xmlns:android="http://schemas.android.com/apk/res/android">

  <style name="ButtonAppTheme" parent="android:Widget.Holo.Light.Button">
      <item name="android:background">@drawable/apptheme_btn_default_holo_light</item>
  </style> 
</resources>

themes_apptheme.xml

<?xml version="1.0" encoding="utf-8"?>

<!-- Generated with http://android-holo-colors.com -->
<resources xmlns:android="http://schemas.android.com/apk/res/android">

  <style name="AppTheme" parent="@style/_AppTheme"/>

  <style name="_AppTheme" parent="Theme.AppCompat.Light">

    <item name="android:editTextBackground">@drawable/apptheme_edit_text_holo_light</item>

    <item name="android:buttonStyle">@style/ButtonAppTheme</item>

  </style>

</resources>

Dans mon Layout.xml fichier, j'ai défini mon bouton comme ci-dessous

<Button
        android:id="@+id/btnAddTitle"
        android:layout_below="@id/edEnterTitleValue"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/btn_AddTitle"
        android:layout_margin="20dp"
/>

Si j'ai ajouter la ligne ci-dessous pour le bouton voir ci-dessus,

android:background="@style/ButtonAppTheme"

Application se bloque en disant que drawable ressource doit être définie pour l'attribut background.

Alors, j'ai créé ci-dessous drawable fichier - abc.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_window_focused="false" android:state_enabled="true"
        android:drawable="@drawable/apptheme_btn_default_normal_holo_light" />
    <item android:state_window_focused="false" android:state_enabled="false"
        android:drawable="@drawable/apptheme_btn_default_disabled_holo_light" />
    <item android:state_pressed="true"
        android:drawable="@drawable/apptheme_btn_default_pressed_holo_light" />
    <item android:state_focused="true" android:state_enabled="true"
        android:drawable="@drawable/apptheme_btn_default_focused_holo_light" />
    <item android:state_enabled="true"
        android:drawable="@drawable/apptheme_btn_default_normal_holo_light" />
    <item android:state_focused="true"
        android:drawable="@drawable/apptheme_btn_default_disabled_focused_holo_light" />
    <item
         android:drawable="@drawable/apptheme_btn_default_disabled_holo_light" />
</selector>

Si j'ai mis android:background="@drawable/abc" je ne vois pas le style de jeu dans le bouton.

De sorte s'il vous plaît laissez-moi savoir comment je peux définir le style du bouton.

Grâce.

OriginalL'auteur Prem | 2014-09-27