I have a really simple image within a RelativeLayout
and for some reason I am getting extra spacing on the top and bottom which I can\'t remove. How can I clear
just add ScaleType="fitxy" inside the Image view
Must be enough adding the property:
android:adjustViewBounds="true"
for example:
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/slice11pp"
android:adjustViewBounds="true" />
In your above imageView
just add android:scaleType="fitXY"
Your problem is probably that you have no scale type set... Add it to the XML for the ImageView, "fitCenter" should be correct, but there are others, check: ScaleType.
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/slice11pp"
android:scaleType="fitCenter" />
Use drawable-nodpi folder if there is no specific requirement for images. Then android: adjustViewBounds = "true"
acts as the default.
If you use drawable-nodpi you don't need to set android:adjustViewBounds = "true"
.
I think this is the most effortless method.
this is the perfect solution
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="fitXY"
/>
it will not leave any extra single dp in any side. however the image will be distorted if it is not portrait image.