DolDurma
DolDurma

Reputation: 17311

Android change imageButton when finger is hover on that

i'm create simple application to work with custom buttom if finger is pressed or released and hover on that. in this simple selector project have 4 state for change background image, but i need to change this button when finger pointer is focus or hover on that but that does not work and only press work correctly in my project.

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_focused="true"
          android:state_pressed="false"
          android:drawable="@drawable/logo"/>


    <item android:state_focused="true"
          android:state_pressed="true"
          android:drawable="@drawable/gohome" />


    <item android:state_focused="false"
          android:state_pressed="true"
          android:drawable="@drawable/goran" />


    <item android:drawable="@drawable/logo" />
</selector>

Upvotes: 1

Views: 142

Answers (1)

Distwo
Distwo

Reputation: 11749

In touch UI there is no such thing as "hover". Hover is when your pointer is over a control. Without having a pointer, you cannot reproduce this step.

You can play with "focused", "pressed" and default.

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_focused="true"
          android:drawable="@drawable/logo"/>

    <item android:state_pressed="true"
          android:drawable="@drawable/goran" />


    <item android:drawable="@drawable/logo" />
</selector>

Upvotes: 1

Related Questions