Skip to content Skip to sidebar Skip to footer

Android-button Background Drawable Doesn't Work

this is my xml drawbale code with the name of btntheme.xml : Copy

after using this if it will not work then if possible try to use image view instead of button i think that will be work. thanks;-)


Solution 2:

navigate to res/values/styles/styles.xml or res/values/themes/themes.xml and change Theme.MaterialComponents.Light.NoActionBar to Theme.AppCompat.Light.NoActionBar

or just replace MaterialComponents with AppCompat


Solution 3:

Try out selector as below:

<!-- Active tab -->
<item android:drawable="@drawable/customactionbartheme_btn_default_normal_holo_light" android:state_focused="false" android:state_pressed="false" android:state_selected="true"/>
<!-- Inactive tab -->
<item android:drawable="@drawable/customactionbartheme_btn_default_pressed_holo_light" android:state_focused="false" android:state_pressed="false" android:state_selected="false"/>
<!-- Pressed tab -->
<item android:drawable="@drawable/customactionbartheme_btn_default_pressed_holo_light" android:state_pressed="true"/>
<!-- Selected tab (using d-pad) -->
<item android:drawable="@drawable/customactionbartheme_btn_default_disabled_holo_light" android:state_focused="true" android:state_pressed="false" android:state_selected="true"/>

</selector>

For more detail guidenc check out Custom Selector in Android


Solution 4:

The problem might be that the screen you are testing on does not use drawable-hdpi, so try to move the images and xml file itself to the drawable folder, if it does not exist then create it.


Solution 5:

issue is with material design that is mentioned in style simple replace it with

<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">

Post a Comment for "Android-button Background Drawable Doesn't Work"