Why does calling setScaleX during pinch zoom gesture cause flicker?

Posted by numan on Stack Overflow See other posts from Stack Overflow or by numan
Published on 2013-06-30T22:59:52Z Indexed on 2013/07/02 23:06 UTC
Read the original article Hit count: 1086

I am trying to create a zoomable container and I am targeting API 14+

In my onScale (i am using the ScaleGestureDetector to detect pinch-zoom) I am doing something like this:

public boolean onScale (ScaleGestureDetector detector) {
   float scaleFactor = detector.getScaleFactor();
   setScaleX(getScaleX() * scaleFactor);
   setScaleY(getScaleY() * scaleFactor);

   return true;
};

It works but the zoom is not smooth. In fact it noticeably flickers.

I also tried it with hardware layer thinking that the scaling would happen on the GPU once the texture was uploaded and thus would be super fast. But it made no difference - the zoom is not smooth and flickers weirdly sometimes.

What am I doing wrong?

© Stack Overflow or respective owner

Related posts about android

Related posts about Performance