I implemented a Custom ImageView based on Nicolas Tyler's post here: https://stackoverflow.com/a/17649895/680488
It works really good but I have one problem:
I have the custom ImageView inside a layout with one other layout below the ImageView. This second layout's visibility can be toggled by the user. Whenever this happens, the ImageView gets resized (to fill the whole activity or make space for the other layout). So far so good. The problem is, that when this re-sizing occurs, the ImageView seems to 'lose' its imagematrix and the image is shown again in its original state (zoomed out, so that the whole image fits on the screen).
I want to keep the last state before the re-sizing (scroll/zoom back to the same position (or just stay there)). So the question is, when is the best situation to store the imageview's matrix and when to apply it again? (onSizeChanged seems to be to late, right?)
I hope it's clear enough...?
EDIT: after I implemented it as described in the comments I now have really weird behavior: It first looks good, and the imageView stays at (or actually goes back to) the same state as it was before the visibility change of the other view. However, when I then touch the view to scroll or zoom, it moves a couple of pixels and then jumps to a completely different position and the controls don't work anymore (I cant scroll/zoom). I printed out the matrix values while touching after resizing:
OnTouch: 1.204599, 0.0, -1254.761, 0.0, 1.204599, -107.23739, 0.0, 0.0, 1.0
OnTouch: 1.204599, 0.0, -1254.761, 0.0, 1.204599, -107.23739, 0.0, 0.0, 1.0
OnTouch: 1.204599, 0.0, -1254.761, 0.0, 1.204599, -107.23739, 0.0, 0.0, 1.0
OnTouch: 1.204599, 0.0, -1254.761, 0.0, 1.204599, -107.23739, 0.0, 0.0, 1.0
OnTouch: 1.204599, 0.0, -1254.761, 0.0, 1.204599, -107.23739, 0.0, 0.0, 1.0
OnTouch: 1.204599, 0.0, -1254.761, 0.0, 1.204599, -107.23739, 0.0, 0.0, 1.0
OnTouch: 1.204599, 0.0, 0.0, 0.0, 1.204599, -107.23739, 0.0, 0.0, 1.0
OnTouch: 1.204599, 0.0, 0.0, 0.0, 1.204599, -107.23739, 0.0, 0.0, 1.0
OnTouch: 1.204599, 0.0, 0.0, 0.0, 1.204599, -107.23739, 0.0, 0.0, 1.0
OnTouch: 1.204599, 0.0, 0.0, 0.0, 1.204599, -107.23739, 0.0, 0.0, 1.0
OnTouch: 1.204599, 0.0, 0.0, 0.0, 1.204599, -107.23739, 0.0, 0.0, 1.0
OnTouch: 1.204599, 0.0, 0.0, 0.0, 1.204599, -107.23739, 0.0, 0.0, 1.0
so TRANS_X is at once jumping to zero. Any ideas why something like this could happen?
Cheers, J