1

I am using below code to display highlighted button when i am in that home page but blow my code is not working so I am not understanding what is the wrong in my xml code.

Can you tell me the correct way please?

<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/button_pressed" android:state_activated="true"/>
 <!-- pressed -->
    <item android:drawable="@drawable/button_pressed" android:state_pressed="true"/>
 <!-- pressed -->
    <item android:drawable="@drawable/button_pressed" android:state_focused="true"/>
 <!-- focused -->
    <item android:drawable="@drawable/list_button" android:state_hovered="true"/>
 <!-- hovered -->
    <item android:drawable="@drawable/button_background"/>
 <!-- default -->

</selector>
Hartok
  • 2,147
  • 20
  • 37
Androi Developer
  • 287
  • 1
  • 4
  • 15

2 Answers2

0

Try this,

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:drawable="@drawable/button_background" android:state_pressed="false"/>
<!-- default -->
<item android:drawable="@drawable/button_pressed" android:state_pressed="true"/>
<!-- pressed -->
</selector>
MuraliGanesan
  • 3,233
  • 2
  • 16
  • 22
0

create xml selector file.

    <item android:drawable="@android:color/transparent" android:state_window_focused="false"/>
    <item android:drawable="@drawable/action_item_selected" android:state_pressed="true"/>
    <item android:drawable="@drawable/action_item_selected" android:state_focused="true"/>
    <item android:drawable="@android:color/transparent"/>

</selector>
Zala Janaksinh
  • 2,929
  • 5
  • 32
  • 58