Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panning to border not possible when zoomed in on multiple TouchImageViews #439

Open
phillies opened this issue Apr 4, 2022 · 4 comments · May be fixed by #456
Open

Panning to border not possible when zoomed in on multiple TouchImageViews #439

phillies opened this issue Apr 4, 2022 · 4 comments · May be fixed by #456

Comments

@phillies
Copy link

phillies commented Apr 4, 2022

Original question here:
https://stackoverflow.com/questions/71524327/zoom-in-zoom-out-and-move-images-in-layers-of-touchimageviews-one-on-top-of-th

I have a few layers of TouchImageViews, one on top of the other. The bottom TouchImageView contains the basic image. Then, each layer adds information on top of it. The user can choose which layers should be shown - for example when the user clicks on a button, analysis TouchImageView is set to visible, and thus the user can see this layer on top of the image.

In order to allow the user to zoom-in, zoom-out and move the image, I used TouchImageView. This works great when only one TouchImageView is shown. When there are multiple shown TouchImageViews, I set a transparent TouchImageView on top of them, which listens to touch events and updates the other TouchImageViews under it

   binding.overlayView.setOnTouchImageViewListener(object : OnTouchImageViewListener {
        override fun onMove() {
            binding.baseView.setZoom(binding.zoomOverlay)
            binding.analysisView.setZoom(binding.zoomOverlay)
            binding.linesView.setZoom(binding.zoomOverlay)
            binding.colorView.setZoom(binding.zoomOverlay)
        }
    })

The problem: the zoom works perfectly, the movement works but not good enough: after zooming in, the movement of the underlying images is limited. They move with the top overlay TouchImageView, but not all the way. They move just a bit, kind of stuck in the middle. I cannot move them all the way to the sides. The top transparent layout moves correctly (I tested it with a background of a ball, and I can move the ball all over the screen).

Here is the layout in xml:

    android:id="@+id/image_view_container"
    android:layout_width="match_parentdp"
    android:layout_height="match_parent">

<com.ortiz.touchview.TouchImageView
    android:id="@+id/baseView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:forceHasOverlappingRendering="false"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<com.ortiz.touchview.TouchImageView
    android:id="@+id/analysisView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/transparent"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<com.ortiz.touchview.TouchImageView
    android:id="@+id/linesView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/transparent"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<com.ortiz.touchview.TouchImageView
    android:id="@+id/colorView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/transparent"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<com.ortiz.touchview.TouchImageView
    android:id="@+id/overlayView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/transparent"
    android:visibility="visible"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

Any ideas?

@hannesa2
Copy link
Collaborator

hannesa2 commented Apr 4, 2022

#314 (comment)

@doplerfish
Copy link

Following the problem #phillies pointed out, here is a complete (and simple) project that shows the problem. After zooming in the pictures are not synchronized properly.
Help would be very appreciated!

https://github.com/doplerfish/touch-image-layers

@phillies
Copy link
Author

@hannesa2 Did you have the time to check @doplerfish s example? I still have the issue with the zoom and pan.

@hannesa2 hannesa2 linked a pull request Jun 17, 2022 that will close this issue
@hannesa2
Copy link
Collaborator

@doplerfish I moved your changes to #456 but till now, I don't see what causes the issue. But maybe more interested guys can investigate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants