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

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

Open
AndroidPat opened this issue Apr 5, 2022 · 5 comments

Comments

@AndroidPat
Copy link

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>
@hannesa2
Copy link
Collaborator

hannesa2 commented Apr 5, 2022

Did you debugged it already ?

@AndroidPat
Copy link
Author

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.

@hannesa2
Copy link
Collaborator

hannesa2 commented Apr 5, 2022

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

@JRWilding
Copy link

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

is overriding the height and basically acting like match_parent

@AndroidPat
Copy link
Author

AndroidPat commented Jul 12, 2022

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

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

No branches or pull requests

3 participants