Martin Erlic
Martin Erlic

Reputation: 5667

How can I crop my ImageView with scaling it proportionally?

I've tried several things but my image always appears as a proportionally scaled down version of itself. I want it to take up the full width available to it and for it to bleed over the image boundaries height-wise.

            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/messageImageLayout"
                android:layout_width="match_parent"
                android:layout_height="150dp"
                android:gravity="center_horizontal|center_vertical">

                <ImageView
                    android:id="@+id/messageImage"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:scaleType="fitXY"
                    android:layout_gravity="center_horizontal"
                    android:layout_marginBottom="5dp"
                    android:layout_marginTop="10dp"
                    android:adjustViewBounds="true"
                    android:src="@drawable/test"
                    android:visibility="gone" />

            </LinearLayout>

How it looks now:

enter image description here

What I want:

enter image description here

Upvotes: 1

Views: 35

Answers (1)

KittoKatto
KittoKatto

Reputation: 544

Replace android:scaleType="fitXY" with android:scaleType="centerCrop" instead

Upvotes: 2

Related Questions