Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom ImageView, keep state after resize
    primarykey
    data
    text
    <p>I implemented a Custom ImageView based on Nicolas Tyler's post here: <a href="https://stackoverflow.com/a/17649895/680488">https://stackoverflow.com/a/17649895/680488</a></p> <p>It works really good but I have one problem:</p> <p>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).</p> <p>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?)</p> <p>I hope it's clear enough...?</p> <p>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:</p> <pre><code>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 </code></pre> <p>so TRANS_X is at once jumping to zero. Any ideas why something like this could happen?</p> <p>Cheers, J</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload