title: Android - Child order in Custom ViewGroup
body: <p>I'm writing a custom <code>ViewGroup</code> which is a simple combination of other views. However, the Views seem to be in arbitrary order.</p>
  
  <p>I know I can implement the <code>getChildDrawingOrder()</code> method but I was curious how the order of the Views was determined in the first place ? </p>
  
  <hr>
  
  <p><strong>UPDATE:</strong> This is a minimum implementation and it works but I don't know why the indicator is always on top no matter what I do</p>
  
  <pre><code>public class PaginatedGallery extends ViewGroup {
  
  ViewPager mPager;
  CirclePageIndicator mPagerIndicator;
  
  public PaginatedGallery(Context context) {
      super(context);
      mPager = new ViewPager(context);
      mPagerIndicator = new CirclePageIndicator(context);
      addView(mPager);
      addView(mPagerIndicator);
  }
  
  public void setAdapter(PaginatedGalleryAdapter adapter) {
      mPager.setAdapter(adapter);
      mPagerIndicator.setViewPager(mPager);
  }
  
  @Override
  protected void onLayout(boolean changed, int l, int t, int r, int b) {
      final int count = getChildCount();
  
      for (int i = 0; i&lt; count; i++ ) {
          getChildAt(i).layout(l, t, r, b);
      }
  
  }   
  }
  </code></pre>
  
  <p>I know I'm not implementing <code>onMeasure()</code> and <code>onLayout()</code> is just plain vanilla but I'm just curious as to why indicator is the first child and not the pager.</p>