Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to deal with touch delay on Android screen?
QtWS25 Last Chance

How to deal with touch delay on Android screen?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
4 Posts 3 Posters 438 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SeeLookS Offline
    SeeLookS Offline
    SeeLook
    wrote on last edited by SeeLook
    #1

    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?

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Rampe
      wrote on last edited by Rampe
      #2

      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" 
                  }
              }
      
      1 Reply Last reply
      0
      • SeeLookS Offline
        SeeLookS Offline
        SeeLook
        wrote on last edited by
        #3

        @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"
        
        1 Reply Last reply
        0
        • C Offline
          C Offline
          Camervin
          Banned
          wrote on last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved