ImageView Has Unwated Padding

214 views Asked by At

I've imported some images from Adobe XD in PNG format to Android Studio. The images seem to come with extra padding. I'm attempting to fill the ImageView with just the size of the imported image (in this case messages).

This is my xml:

<ImageView
    android:src="@drawable/messages"
    android:id="@+id/imageView5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"
    tools:layout_editor_absoluteX="79dp"
    tools:layout_editor_absoluteY="184dp" />

These images show what the padding looks like:

Example 1: image has padding

Example 2: ImageView is quite larger than the actual image.

Is there anyway to get the ImageView to wrap around the image exactly without the padding?

Thank you for your help.

1

There are 1 answers

4
Shamir Kp On BEST ANSWER

Try using android:scaleType:

<ImageView
    android:src="@drawable/messages"
    android:id="@+id/imageView5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"
    android:scaleType="fitXY" 
    tools:layout_editor_absoluteX="79dp"
    tools:layout_editor_absoluteY="184dp" />