示例#1
0
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    // Cache off the measure spec
    mHeightMeasureSpec = heightMeasureSpec;
  };
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    int n = getChildCount();
    for (int i = 0; i < n; i++) measureView(getChildAt(i));
  }
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    for (View child : bufferedViews) {
      child.measure(widthMeasureSpec, heightMeasureSpec);
    }

    surfaceView.measure(widthMeasureSpec, heightMeasureSpec);
  }
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    int requestedWidth = getMeasuredWidth() - getPaddingLeft() - getPaddingRight();
    int requestedHeight = getMeasuredHeight() - getPaddingTop() - getPaddingBottom();
    int childWidth, childHeight;

    if (mOrientation == Orientation.Disordered) {
      int R1, R2;
      if (requestedWidth >= requestedHeight) {
        R1 = requestedHeight;
        R2 = requestedWidth;
      } else {
        R1 = requestedWidth;
        R2 = requestedHeight;
      }
      childWidth =
          (int)
              ((R1 * Math.cos(DISORDERED_MAX_ROTATION_RADIANS)
                      - R2 * Math.sin(DISORDERED_MAX_ROTATION_RADIANS))
                  / Math.cos(2 * DISORDERED_MAX_ROTATION_RADIANS));
      childHeight =
          (int)
              ((R2 * Math.cos(DISORDERED_MAX_ROTATION_RADIANS)
                      - R1 * Math.sin(DISORDERED_MAX_ROTATION_RADIANS))
                  / Math.cos(2 * DISORDERED_MAX_ROTATION_RADIANS));
    } else {
      childWidth = requestedWidth;
      childHeight = requestedHeight;
    }

    int childWidthMeasureSpec, childHeightMeasureSpec;
    childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(childWidth, MeasureSpec.AT_MOST);
    childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(childHeight, MeasureSpec.AT_MOST);

    for (int i = 0; i < getChildCount(); i++) {
      View child = getChildAt(i);
      assert child != null;
      child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
    }
  }
示例#5
0
 /*
  *(non-Javadoc)
  * @see android.view.View#onMeasure(int,int)
  */
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   final int width = MeasureSpec.getSize(widthMeasureSpec);
   final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
   if (widthMode != MeasureSpec.EXACTLY && !isInEditMode()) {
     throw new IllegalStateException("ViewFlow can only be used in EXACTLY mode.");
   }
   final int heightMode = MeasureSpec.getMode(heightMeasureSpec);
   if (heightMode != MeasureSpec.EXACTLY && !isInEditMode()) {
     throw new IllegalStateException("ViewFlow can only be used in EXACTLY mode.");
   }
   final int count = getChildCount();
   for (int i = 0; i < count; i++) {
     getChildAt(i).measure(widthMeasureSpec, heightMeasureSpec);
   }
   if (mFirstLayout) {
     mScroller.startScroll(0, 0, mCurrentScreen * width, 0, 0);
     mFirstLayout = false;
   }
 }