Nestarneal
Nestarneal

Reputation: 305

Wrong coordinates after TranslateAnimation

The resolution of my device is 1080*1920 (portrait), and the size of my webview is 1080*960

I use TranslateAnimation on WebView to translate it from y=0 to y=960.

TranslateAnimation animation = new TranslateAnimation(0f, 0f, 0f, 960f);
animation.setDuration(300);
animation.setFillAfter(true);

webview.startAnimation(animation);

Android help me to draw the webview to y=960, but I cannot trigger any touch event in the y range [960, 1920], instead, my touch event is triggered in the y range [0, 960].

It seems some control component or other things didn't be translated to y=960 with the webview.

Is there any method to translate the control also to y=960, or other better solution is recommended?

Many thanks.

Upvotes: 1

Views: 93

Answers (1)

azizbekian
azizbekian

Reputation: 62189

TranslateAnimation animates the matrix, not the View itself. So, you end up seeing an illusion: you see a View which in fact has other coordinates.

Either you need to change WebView coordinates after animation ends, or you can use fluent API instead of TranslateAnimation:

webview.animate()
       .y(960f)
       .setDuration(300);

Upvotes: 2

Related Questions