title: How to Increase the size of Image View in Android
body: <p>I am working on a project that requires me to implement <strong>two horizontal scroll views</strong> with an <strong>image view in between</strong> them. I would like to extend the size of the image view to fill up the gap in between the scroll view. I went through the sample code, but it doesn't seem to mention anywhere in the size of the image view. I've enclosed the code below after the Image describing my problem.</p>
  
  <p><img src="https://i.stack.imgur.com/ElBTN.jpg" alt="enter image description here"></p>
  
  <pre><code>public class Gallery2DemoActivity extends Activity {
  private Gallery gallery,gallery1;
  private ImageView imgView;
  
  private Integer[] Imgid = {
      R.drawable.a_1, R.drawable.a_2, R.drawable.a_3, R.drawable.a_4, R.drawable.a_5, R.drawable.a_6, R.drawable.a_7
  };
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  
  gallery = (Gallery) findViewById(R.id.examplegallery);
  gallery.setAdapter(new AddImgAdp(this));
  
  gallery1 = (Gallery)findViewById(R.id.examplegallery1);
  gallery1.setAdapter(new AddImgAdp(this));
  
  imgView = (ImageView)findViewById(R.id.ImageView01);    
  imgView.setImageResource(Imgid[0]);
  
  
   gallery.setOnItemClickListener(new OnItemClickListener() {
      public void onItemClick(AdapterView parent, View v, int position, long id) {
          imgView.setImageResource(Imgid[position]); 
      }
  });
  
  }
  
  public class AddImgAdp extends BaseAdapter {
  int GalItemBg;
  private Context cont;
  
  public AddImgAdp(Context c) {
      cont = c;
      TypedArray typArray = obtainStyledAttributes(R.styleable.GalleryTheme);
      GalItemBg =  typArray.getResourceId(R.styleable.GalleryTheme_android_galleryItemBackground, 0);
      typArray.recycle();
  }
  
  public int getCount() {
      return Imgid.length;
  }
  
  public Object getItem(int position) {
      return position;
  }
  
  public long getItemId(int position) {
      return position;
  }
  
  public View getView(int position, View convertView, ViewGroup parent) {
      ImageView imgView = new ImageView(cont);
  
      imgView.setImageResource(Imgid[position]);
      imgView.setLayoutParams(new Gallery.LayoutParams(110, 100));
      imgView.setScaleType(ImageView.ScaleType.FIT_XY);
      imgView.setBackgroundResource(GalItemBg);
  
      return imgView;
  }
  }
  </code></pre>
  
  <p>This is my XML main file.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/LinearLayout01"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical" &gt;
  &lt;Gallery
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/examplegallery"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content" /&gt;
  &lt;ImageView
      android:id="@+id/ImageView01"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" 
      android:layout_weight="1"/&gt;
  &lt;Gallery
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/examplegallery1"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Below is my Attributes file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources&gt;
  &lt;declare-styleable name="GalleryTheme"&gt;
      &lt;attr name="android:galleryItemBackground" /&gt;
  &lt;/declare-styleable&gt;
  &lt;/resources&gt;
  </code></pre>