How to achieve in android something like on_hover in css ? I want to images in buttons be more light when touch. I have those lightier images but I don't know where to save them.
Asked
Active
Viewed 201 times
2 Answers
1
You could look at the onTouchListener
You will get something like this:
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if(motionEvent == MotionEvent.ACTION_HOVER_MOVE){
//change image
return true;
}
else {
return false;
}
}
Just take a look at the documentation here

Jordy Langen
- 3,591
- 4
- 23
- 32
1
use this below selector.xml and put your image in your drawable folder. call your button background as android:background="@drawable/selector".
<item android:state_pressed="true"
android:drawable="@drawable/darkimage" >
</item>
<item android:state_focused="true"
android:drawable="@drawable/darkimage" >
</item>
<item android:drawable="@drawable/lighterimage" >
</item>

Padma Kumar
- 19,893
- 17
- 73
- 130