TouchImageView icon indicating copy to clipboard operation
TouchImageView copied to clipboard

The TouchImageView is not correctly wrapped vertically when wrap content is used.

Open AndroidPat opened this issue 2 years ago • 5 comments

Same issue as #256

I am trying to wrap the TouchImageView with a border but there is an unpredictable artificial space at the top and bottom of the image when I use wrap_content for height. Layout inspector is showing the empty space belongs to the TouchImageView. it seems like adjustViewBounds = true is not applied. The problem is illustrated below. The image with the correctly wrapped view is using the AppCompatImageView, the other one uses TouchImageView. I am aware that TouchImageView extends AppCompatImageView so I guess the issue is somewhere in the additional code handling image resizing in TouchImageView. TouchImageView AppCompatImageView

Changing the view type below to TouchImageView breaks it.

<androidx.appcompat.widget.AppCompatImageView
                    android:id="@+id/iv_test"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="16dp"
                    android:layout_marginTop="16dp"
                    android:layout_marginEnd="16dp"
                    android:layout_marginBottom="16dp"
                    android:adjustViewBounds="true"
                    android:scaleType="fitCenter"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

AndroidPat avatar Apr 05 '22 14:04 AndroidPat

Did you debugged it already ?

hannesa2 avatar Apr 05 '22 15:04 hannesa2

I could not figure out why this is happening that's why I decided to post here in case contributors already know why this is happening.

AndroidPat avatar Apr 05 '22 15:04 AndroidPat

I at least don't know what's wrong here

hannesa2 avatar Apr 05 '22 15:04 hannesa2

app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"

is overriding the height and basically acting like match_parent

JRWilding avatar Jul 12 '22 09:07 JRWilding

Hi @JRWilding, you can see in the second screenshot that's not the case.

AndroidPat avatar Jul 12 '22 09:07 AndroidPat