views:

139

answers:

2

I have a simple LinearLayout in Android with two images vertically:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.eataly.android" 
    android:orientation="vertical"
    android:background="@android:color/white"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <ImageView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/img_header1"
        />

    <ImageView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/img_header2"
        />
</LinearLayout>

As you can see at the following link, I can't get rid of a a gap at the top and at the bottom of the images: http://img185.imageshack.us/img185/8484/senzanomev.png

I've tried everything imaginable on the LinearLayout and the ImageViews, i.e.:

android:padding="0px"
android:top="0px"
android:bottom="0px"
android:top="0px"
android:layout_margin="0px"

with no success. What can I do to remove these empty borders?

A: 

To do this in a linearlayout
for the top ImageView: android:gravity="bottom"
for the bottom ImageView: android:gravity="top"
Are you sure you don't want to be using a RelativeLayout? If you're trying to align two images to each other, that seems the way to go for down the road imho.

QRohlf
RelativeLayout doesn't seem to solve the problem: it seems that the ImageView is higher than it should be, so both LinearLayout and RelativeLayout perform the same way.Actually the suggestion above (setting negative values for layout_marginTop) seems to work instead, so it must be an ImageView's problem, not a layout problem.
Enrico Detoma
A: 

I found the solution. I needed to add this attribute to the ImageView:

android:adjustViewBounds="true"
Enrico Detoma