Jompa234
Jompa234

Reputation: 1248

Imageviews in a linearlayout

I am trying to add 4 imageViews to a verticaly aligned LinearLayout. I want the four images to be perfectly stacked with no spacing. The problem is that there is empty space above and below the images. Maybe this has something to do with the way the images get scaled?

Here is my source:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <com.google.ads.AdView
         xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
         android:id="@+id/add1"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         ads:adSize="BANNER"
         ads:adUnitId=""
         ads:loadAdOnCreate="true"
         ads:testDevices="" />

    <ScrollView
        android:id="@+id/scrollView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/add1" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent" 
            android:orientation="vertical" >

            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/menu_graphic_1"/>

             <ImageView
                 android:id="@+id/imageView2"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:src="@drawable/menu_graphic_2" />
            <ImageView
                 android:id="@+id/imageView1"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:src="@drawable/menu_graphic_3" />

             <ImageView
                 android:id="@+id/imageView2"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:src="@drawable/menu_graphic_4" />

        </LinearLayout>

     </ScrollView>

</RelativeLayout>

Upvotes: 1

Views: 105

Answers (1)

Jompa234
Jompa234

Reputation: 1248

Asok is right. Adding android:adjustViewBounds="true" to my ImageView's fixed the problem :)

Upvotes: 1

Related Questions