1

There is a problem with the synchronization of the location of buttons on top of the imageView - when the image stretched button remains in place. I want the buttons to move in synchronism in accordance with the imageView zoom (while keeping the aspect ratio). enter image description here

On attached picture you may see problem. Buttons (icons [V]) remains theirs positions when i resize image by gesture. I want to automatically move buttons when image resizing and dragging.

this is my layout:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/floorPlanLayout"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".OrderActivity">

    <com.github.chrisbanes.photoview.PhotoView
        android:id="@+id/imageViewFloorPlan"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/ic_placeholder"
        />

    <android.support.constraint.ConstraintLayout
        android:id="@+id/buttonsLayout"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:background="@drawable/imageview_border_background">

    </android.support.constraint.ConstraintLayout>

</android.support.constraint.ConstraintLayout>
Aleks Boev
  • 630
  • 1
  • 7
  • 16
  • This is difficult to help you since I cannot understand what you desire. Can you please add an Image of the result you want. it will become much easier for not only me but for everyone else. – Daksh Agrawal Aug 30 '18 at 09:44
  • I try to explain more clearly. Please see attached picture - icons marked [V] (which is buttons) keep theirs positions while image resizing, but i want that buttons will be move to new positions according to image size. – Aleks Boev Aug 30 '18 at 10:47
  • 1
    Seems like this can help : https://stackoverflow.com/questions/10013906/android-zoom-in-out-relativelayout-with-spread-pinch . Set the Image as the background of the RelativeLayout and put the Icons in the layout. – Daksh Agrawal Aug 30 '18 at 15:56
  • Thank you so much! You are saved my time! – Aleks Boev Sep 04 '18 at 09:15

1 Answers1

1

In my case its better to use layout with background than imageview (thanks to Daksh Agrawal). When i reviewed more about proposed solution (Android - zoom in/out RelativeLayout with spread/pinch) i found that its not quite flexible for me. After a little search i found that: https://github.com/natario1/ZoomLayout. Its several utilities which help to zoom and pan Layout and imageView very easy. Hope it helps someone.

Aleks Boev
  • 630
  • 1
  • 7
  • 16