【发布时间】:2018-09-04 17:30:47
【问题描述】:
imageView 顶部按钮位置的同步存在问题 - 当图像拉伸按钮保持在原位时。我希望按钮根据 imageView 缩放同步移动(同时保持纵横比)。
在附加的图片上,您可能会看到问题。当我通过手势调整图像大小时,按钮(图标 [V])保持其位置。我想在图像调整大小和拖动时自动移动按钮。
这是我的布局:
<?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>
【问题讨论】:
-
这很难帮助你,因为我无法理解你想要什么。您能否添加您想要的结果的图像。不仅对我,对其他人来说,这都会变得容易得多。
-
我尽量解释清楚。请参阅附图 - 标记为 [V] 的图标(即按钮)在调整图像大小时保持其位置,但我希望按钮将根据图像大小移动到新位置。
-
似乎这样可以提供帮助:stackoverflow.com/questions/10013906/…。将Image设置为RelativeLayout的背景,并将Icons放入布局中。
-
非常感谢!你节省了我的时间!