Code example for ViewPager

Methods: getChildAt, getMeasuredWidth, onMeasure, setMeasuredDimension

1
      super(context, attrs);
   } 
 
   @Override 
   protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
      super.onMeasure(widthMeasureSpec, heightMeasureSpec);
 
      // find the first child view 
      View view = getChildAt(0);
      if (view != null) {
         // measure the first child view with the specified measure spec 
         view.measure(widthMeasureSpec, heightMeasureSpec);
      } 
 
      setMeasuredDimension(getMeasuredWidth(), measureHeight(heightMeasureSpec, view));
   } 
 
   /** 
    * Determines the height of this view 
    *  
    * @param measureSpec