Reputation: 1447
This question has been asked many times, but none of the answers helped.
Android adds adds extra white space on all the four sides of image in ImageView
. And this is same for devices different of different screen size. I have tried changing resolution of the image(s) as well, but to no avail.
For reference, here is my xml code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".Starter" >
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:contentDescription="cat"
android:scaleType="fitXY"
android:src="@drawable/splash" />
</LinearLayout>
Also attached is the screenshot how the image looks like.
How can I remove these spaces ?
Thanks.
Upvotes: 0
Views: 1050
Reputation: 46856
remove these lines:
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
And ensure that the whitespace is not a part of your image file itself.
Upvotes: 1