How to deal with touch delay on Android screen?
-
Hello everyone,
It seems that on any Android device animations as such as tapping button and so are not displayed.
It appears like the button action is triggered before the animation becomes visible.
To be concrete, if we want to change button background during tap/press:color: pressed ? "red" : "gray"
it will never appear on Android.
What is interesting, if we touch the screen in some inactive area with one finger and then tap such a button with another one - it will work just fine like it works always on the desktop.Is there any common way how to handle that for Android?
-
Hi there,
On latest Qt 6.3.0 Beta using QML on Android 10 below snippet seem to work (at least for me..). Please take into account that Button does not have color property. Hope this helps.
Button { id: exampleButton anchors.top: parent.top anchors.left: parent.left anchors.margins: 20 focusPolicy: Qt.NoFocus text: "Sample" background: Rectangle{ implicitHeight: exampleButton.Height implicitWidth: exampleButton.Width color: exampleButton.pressed ? "red" : "blue" } }
-
@Rampe , thank You for the answer.
But it is not exactly I was asking about.
This is not about how to implement press animation.
The problem is that such the animation - this code snippet You gave is great example - is not visible on Android device...
In "normal" way - I mean when one just tap quickly the button - It appears only when a finger remains on the button a bit longer, or if it is a second finger as I wrote in the first post.But I found a culprit...
It is a screen protection glass/film which causes delay in a touch.
Without that thingy it works as intended.
So this solves my issue.Anyway, native Android animations for button pressing have kinda workaround, that the animation is shown even after delay.
So I come up with the hack:
(it applies to @Rampe code as well)property bool innerPress: pressAnim.running || pressed onPressed: pressAnim.start() PauseAnimation { id: pressAnim; duration: 100 } // then color: innerPress ? "red" : "blue"