title: How to programmatically  add ImageView in LinearLayout without extra spaces?
body: <p>I am trying to add ImageView programatically inside a LinearLayout, which has vertical orientation. My layout file is describe as the xml below:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:paddingTop="5dip"
     android:id="@+id/mainView""&gt;
  
     &lt;TextView android:id="@+id/tvTituloInformacao"
      android:layout_width="fill_parent"          
      android:layout_height="wrap_content"
      android:textSize="20sp"
      android:textStyle="bold"
      android:textColor="@color/white"
      android:gravity="center_horizontal"
      android:shadowColor="@color/black_translucent"
      android:shadowDx="2.0"
      android:shadowDy="2.0"
      android:shadowRadius="3.0"
      android:layout_alignParentTop="true"
      android:layout_alignParentLeft="true" /&gt; 
  
      &lt;LinearLayout android:id="@+id/resourceContainer"
      android:layout_width="fill_parent"          
      android:layout_height="wrap_content"
      android:layout_marginTop="5dip"
      android:layout_marginLeft="10dip"
      android:layout_marginRight="10dip"
      android:layout_marginBottom="10dip"
      android:padding="3dip"
      android:orientation="vertical"
      android:gravity="center_horizontal"
      android:layout_below="@+id/tvTituloInformacao"
      android:background="@color/black_translucent2" /&gt; 
  
   &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>And my java source code that adds the ImageViews to the LinearLayout is as follow:</p>
  
  <pre><code>for(Resource r : mUser.getPictures()) {
      ImageView img = new ImageView(this);
      img.setVisibility(View.VISIBLE);
      img.setTag(r.getThumb60());
      imageLoader.DisplayImage(r.getThumb60(), this, img);
      ((LinearLayout) tempFotosView.findViewById(R.id.resourceContainer)).addView(img);
  }
  </code></pre>
  
  <p>What happens is that before and after each ImageView I am getting some extra spaces that should not be there, so the height of the images container increases a lot. One test that I did and got the expected result was not to use the imageLoader and instead I set the ImageResource programatically to a static image file. This way I didn't get any extra space.</p>
  
  <p>The weird result is illustrated in the image below:</p>
  
  <p><img src="https://i.stack.imgur.com/c8oIK.png" alt="enter image description here"></p>
  
  <p>Is there a way to not add this extra space?</p>