Skip to content Skip to sidebar Skip to footer

Onhoverlistener Doesn't Work In Android

In android document, it mentions supporting the 'hover' event since 4.0 (ie. API level 14 and up). But somehow, it doesn't work. Even I tried out the sample code in ApiDemo, which

Solution 1:

Hovering requires support from the hardware. The only thing likely to support it is a stylus. It won't work with just your finger.

Solution 2:

try using OnFocusChangeListener(). PS worked for me

Solution 3:

I suggest to Turn on 'Accessibility' and 'Explore by touch' feature in settings. When these features are off, the hover action will be treated as touch actions.

Solution 4:

setOnTouchListener is also an option. Here is a kotlin example:

    binding.ratingBar.setOnTouchListener { v, event ->
        println("touch......")
        false
    }

here (binding.ratingBar) is my view reference. I used view binding.

Post a Comment for "Onhoverlistener Doesn't Work In Android"