Lucas Heise
Lucas Heise

Reputation: 149

How to fix imageview width - Not filling whole screen width

I'm creating an app that uses an ImageView in the main activity that covers the whole width of the screen, the height should fit the image's resolution.

Here's my xml:

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <ImageView
        android:adjustViewBounds="true"
        android:id="@+id/bgImage"
        android:scaleType="fitXY"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/bg_home_blue"/>

</RelativeLayout>

Here's what my layout looks like:

enter image description here

Everything seems to work fine but I don't know where these paddings are coming from, I've tried to change the scaleType but nothing seems to work.

Edit:

If I put instead of src just a blue background, the paddings go away and it fills the whole width (than I need to set a specific height as well)

Upvotes: 0

Views: 770

Answers (1)

Arash Afsharpour
Arash Afsharpour

Reputation: 1302

I guess your image is png and have that space around it, even when your scaleType is FitXY it doesn't mean that it will remove the space around the png file, check that out and let us know what happened, or at least upload your image file

Upvotes: 1

Related Questions