Oversized Android Custom Zoom Animation

I have a little specific problem, but hopefully someone will call and help.

I wrote a custom zoom animation (wrapping runnables that changes the target view to a handler between a certain amount of time), but when I change the width and height of the view, it happens as if I were scaling (0, 0), whereas I want to scale its center, so I move the view by changing its fields accordingly. The fact is that when the zoom iteration step is too small (i.e., 0.01f or less), I have to change the field of view by about 1px sometimes in only one direction, which makes it look like an animation It’s buggy, I’m not sure for sure, but I have tried the following things:

1) I tried to change the fields by overriding the onLayout () of my parent view, which would be changed when setting layoutParams when scaling (I did this to avoid the second call to setLayoutParams () when moving, which now actually doesn't seem to be quite reasonable , since setLayoutParams () just sets some flag to be used later).

2) I check the new fields for installation so that they are set only when the difference between the new and old fields is in both the X and Y directions.

3) I tried using view.offsetLeftAndRight () view.offsetTopAndBottom () instead of changing the layout options to move the view, but that did not help again.

Any suggestions what the trick will do?

+4
source share
1 answer

If I understand you correctly, you need to get the Bitmap cache and view it manually. In this case, the bitmap will be drawn without fail (if bitmap filtering is enabled).

You can do this in the following steps:

  • get presentation cache - through View.getDrawingCache or by calling the View.draw function
  • hide view
  • get the current system time - SystemClock.elapsedRealtime (thanks to this, you can calculate the progress of the animation)
  • start publishing runnables to nullify your screen and check if the animation is complete.
  • show performance

Perhaps this can be done using the Android Animation class, but I do not use it, since it is rather limited.

+1
source

All Articles