Skip to content

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

@phillies

Description

@phillies

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions