title: Why does my ViewPager have children of zero width and height?
body: <p>I'm making a ViewPager to display a series of images, which are identified by their position in an array of resource values.  Here is my <code>instantiateItem</code> code for the adapter:</p>
  
  <pre><code>//indexes the images
  @Override
  public boolean isViewFromObject(View arg0, Object arg1) {
      return arg0.getTag().equals(arg1);
  }
  
  //serves the views
  @Override
  public Object instantiateItem(ViewGroup container, int position) {
      ImageView view = new ImageView(container.getContext());
      view.setScaleType(ScaleType.FIT_CENTER);
      view.setTag(position);
      view.setImageResource(mImages.get(position));
      container.addView(view, position);
      return view;
  }
  </code></pre>
  
  <p>It doesn't display.  Looking at <code>container.getChildAt(0)</code> confirms that the layout parameters are set to <code>MATCH_PARENT</code> but the width and height are 0.  The container's own width and height are the screen dimensions (as expected).</p>
  
  <p>Changing the code to</p>
  
  <pre><code>@Override
  public Object instantiateItem(ViewGroup container, int position) {
      ImageView view = (ImageView) View.inflate(container.getContext(), R.layout.imageview, null);
      view.setScaleType(ScaleType.FIT_CENTER);
      view.setTag(position);
      view.setImageResource(mImages.get(position));
      container.addView(view, position);
      return view;
  }
  </code></pre>
  
  <p>(where <code>R.layout.imageview</code> is just a layout with an <code>ImageView</code> in) didn't work.  Setting the background colour to arbitrary visible values shows that the views are essentially not visible.  What's going on?</p>