예제 #1
1
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   int widthmode = MeasureSpec.getMode(widthMeasureSpec);
   int widthsize = MeasureSpec.getSize(widthMeasureSpec);
   int heightmode = MeasureSpec.getMode(heightMeasureSpec);
   int heightsize = MeasureSpec.getSize(heightMeasureSpec);
   if (widthmode == MeasureSpec.AT_MOST && heightmode == MeasureSpec.AT_MOST) {
     setMeasuredDimension(
         (int) mTextSize * text.length() + getPaddingLeft() + getPaddingRight(),
         (int) mTextSize
             + getPaddingTop()
             + getPaddingBottom()
             + DensityUtil.px2dip(mContext, 300));
   } else if (widthmode == MeasureSpec.AT_MOST) {
     setMeasuredDimension(
         (int) mTextSize * text.length() + getPaddingLeft() + getPaddingRight(), heightsize);
   } else if (heightmode == MeasureSpec.AT_MOST) {
     setMeasuredDimension(
         widthsize,
         (int) mTextSize
             + getPaddingTop()
             + getPaddingBottom()
             + DensityUtil.px2dip(mContext, 300));
   }
 }
예제 #2
0
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    int height = getMeasuredHeight();
    setMeasuredDimension(height, height);
  }
예제 #3
0
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   width = getDefaultSize(getSuggestedMinimumWidth(), widthMeasureSpec);
   height = getDefaultSize(getSuggestedMinimumHeight(), heightMeasureSpec);
   setMeasuredDimension(width, height);
 }
예제 #4
0
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int wSize = MeasureSpec.getSize(widthMeasureSpec);
    int hSize = MeasureSpec.getSize(heightMeasureSpec);

    int wMode = MeasureSpec.getMode(widthMeasureSpec);
    int hMode = MeasureSpec.getMode(heightMeasureSpec);

    switch (wMode) {
      case MeasureSpec.EXACTLY:
        // NOP
        break;

      case MeasureSpec.AT_MOST:
      case MeasureSpec.UNSPECIFIED:
        wSize = 0;
        break;
    }

    switch (hMode) {
      case MeasureSpec.EXACTLY:
        // NOP
        break;

      case MeasureSpec.AT_MOST:
      case MeasureSpec.UNSPECIFIED:
        hSize = 0;
        break;
    }

    super.onMeasure(
        MeasureSpec.makeMeasureSpec(wSize, wMode), MeasureSpec.makeMeasureSpec(hSize, hMode));
  }
예제 #5
0
 /** 测量ScaleView的方法, */
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   int widthSize = getWidthSize(widthMeasureSpec);
   int heightSize = getHeightSize(heightMeasureSpec);
   setMeasuredDimension(widthSize, heightSize);
 }
예제 #6
0
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   float dw = 64 * scale;
   float dh = 64 * scale;
   setMeasuredDimension((int) dw, (int) dh);
 }
예제 #7
0
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   int widthDimension = (int) dp2px(100);
   int heightDimension = (int) dp2px(20);
   setMeasuredDimension(widthDimension, heightDimension);
 }
예제 #8
0
 // ----------------------------------
 // Setting up stuff
 // ----------------------------------
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   int viewWidth = circleRadius + this.getPaddingLeft() + this.getPaddingRight();
   int viewHeight = circleRadius + this.getPaddingTop() + this.getPaddingBottom();
   int widthMode = MeasureSpec.getMode(widthMeasureSpec);
   int widthSize = MeasureSpec.getSize(widthMeasureSpec);
   int heightMode = MeasureSpec.getMode(heightMeasureSpec);
   int heightSize = MeasureSpec.getSize(heightMeasureSpec);
   int width;
   int height;
   // Measure Width
   if (widthMode == MeasureSpec.EXACTLY) {
     // Must be this size
     width = widthSize;
   } else if (widthMode == MeasureSpec.AT_MOST) {
     // Can't be bigger than...
     width = Math.min(viewWidth, widthSize);
   } else {
     // Be whatever you want
     width = viewWidth;
   }
   // Measure Height
   if (heightMode == MeasureSpec.EXACTLY || widthMode == MeasureSpec.EXACTLY) {
     // Must be this size
     height = heightSize;
   } else if (heightMode == MeasureSpec.AT_MOST) {
     // Can't be bigger than...
     height = Math.min(viewHeight, heightSize);
   } else {
     // Be whatever you want
     height = viewHeight;
   }
   setMeasuredDimension(width, height);
 }
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    int widthMode = MeasureSpec.getMode(widthMeasureSpec);
    int widthSize = MeasureSpec.getSize(widthMeasureSpec);
    int heightMode = MeasureSpec.getMode(heightMeasureSpec);
    int heightSize = MeasureSpec.getSize(heightMeasureSpec);
    int width;
    int height;
    // 代表设置了具体的数值,就用界面传递过来的
    if (widthMode == MeasureSpec.EXACTLY) {
      width = widthSize;
    } else {
      // 其他模式就自己计算
      width = (int) (getPaddingLeft() + mRadius * 2 + mStrokeWidth * 2 + getPaddingRight());
    }

    if (heightMode == MeasureSpec.EXACTLY) {
      height = heightSize;
    } else {
      height = (int) (getPaddingTop() + mRadius * 2 + mStrokeWidth * 2 + getPaddingBottom());
    }

    setMeasuredDimension(width, height);
  }
예제 #10
0
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    // setMeasuredDimension(calculateMeasuredWidth(), calculateMeasureHeight());

    final int heightMode = MeasureSpec.getMode(heightMeasureSpec);
    final int heightSize = MeasureSpec.getSize(heightMeasureSpec);

    LayoutParams lp = getLayoutParams();
    // 获取IndexBar顶部和底部的margin,这里不用关心左右两边的margin
    int margin = 0;
    // 如果布局文件使用了margin属性时,需要根据margin、mAlphabetTextSize、
    if (lp instanceof ViewGroup.MarginLayoutParams) {
      ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) lp;
      margin = mlp.topMargin + mlp.bottomMargin;
    }

    /**
     * 判断IndexBar高度的裁剪模式,如果{@link heightMode} 为{@link MeasureSpec#EXACTLY},
     * 表示用户设置了一个确切的高度值,或者使用了{@link LayoutParams#MATCH_PARENT}属性。 如果{@link heightMode} 为 {@link
     * MeasureSpec#AT_MOST}, 表示用户使用了{@link LayoutParams#WRAP_CONTENT}属性,这时,我们会使用默认的{@link
     * #mAlphabetPadding}, 或者用户设置的值
     */
    if (heightMode == MeasureSpec.EXACTLY) { // 计算mAlphabetPadding
      final int length = mSections.length;
      mAlphabetPadding = (heightSize - length * mAlphabetTextSize - margin) / (length + 1);

      setMeasuredDimension(widthMeasureSpec, heightMeasureSpec);
    } else {
      setMeasuredDimension(calculateMeasuredWidth(), calculateMeasureHeight());
    }
  }
예제 #11
0
 @Override
 protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) {
   int w = getPartsWidth();
   int h = getPartsHeight();
   super.onMeasure(w, h);
   setMeasuredDimension(w, h);
 }
예제 #12
0
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    widthSize = MeasureSpec.getSize(widthMeasureSpec);
    heightSize = (int) mRadius * 2 + getPaddingBottom() + getPaddingTop();
    setMeasuredDimension(widthSize, heightSize);
  }
예제 #13
0
  // Set the size of the controll
  protected void onMeasure(int widthSpec, int heightSpec) {
    super.onMeasure(widthSpec, heightSpec);

    int width = calculateWidth(widthSpec);
    int height = calculateHeight(heightSpec);

    setMeasuredDimension(width, heightSpec);
  }
예제 #14
0
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    viewHeight = getMeasuredHeight();
    viewWidth = getMeasuredWidth();
    mTextheight = viewHeight / indexStr.length();
  }
예제 #15
0
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

    // keep aspect ratio
    int parentWidth = MeasureSpec.getSize(widthMeasureSpec);
    int myHeight = (int) (parentWidth / 9.0 * 11.0);
    super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(myHeight, MeasureSpec.EXACTLY));
  }
예제 #16
0
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    if (getMeasuredWidth() > getHeight()) mWidth = getMeasuredHeight();
    else mWidth = getMeasuredWidth();
    mPadding = dip2px(1);
  }
예제 #17
0
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   //        mMeasureWidth = MeasureSpec.getSize(widthMeasureSpec);
   //        mMeasureHeigth = MeasureSpec.getSize(heightMeasureSpec);
   //        setMeasuredDimension(mMeasureWidth, mMeasureHeigth);
   //        initView();
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
 }
예제 #18
0
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   mDurationStringWidth = (int) mTextPaint.measureText(mDurationString);
   mTotalDurationStringWidth = (int) mTextPaint.measureText(mTotalDurationString);
   mTextAscent = (int) mTextPaint.ascent();
   mTextDescent = (int) mTextPaint.descent();
 }
예제 #19
0
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   View praent = (View) getParent();
   if (praent != null) {
     mPraentWidth = praent.getWidth();
     mPraentHeight = praent.getHeight();
   }
 }
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   controlWidth = getWidth();
   if (controlWidth != 0) {
     setMeasuredDimension(getWidth(), itemNumber * unitHeight);
     controlWidth = getWidth();
   }
 }
예제 #21
0
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   int width =
       MeasureSpec.makeMeasureSpec(
           getPaddingLeft()
               + getPaddingRight()
               + (int) (mColumnCount * (mDotSizeRadiusPx * 4 - 2)),
           MeasureSpec.EXACTLY);
   super.onMeasure(width, heightMeasureSpec);
 }
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   int height = MeasureSpec.getSize(heightMeasureSpec);
   if (height > PULL_DELTA + PULL_HEIGHT) {
     heightMeasureSpec =
         MeasureSpec.makeMeasureSpec(
             PULL_DELTA + PULL_HEIGHT, MeasureSpec.getMode(heightMeasureSpec));
   }
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
 }
예제 #23
0
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    final int width = getMeasuredWidth();
    final int height = getMeasuredHeight();

    viewWidthHalf = width / 2;
    viewHeightHalf = height / 2;
    radius = (viewWidthHalf > viewHeightHalf) ? viewHeightHalf - 1 : viewWidthHalf - 1;
  }
예제 #24
0
파일: BottomView.java 프로젝트: Claner/App
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   int iconWidth =
       Math.min(
           getMeasuredWidth() - getPaddingLeft() - getPaddingRight(),
           getMeasuredHeight() - getPaddingTop() - getPaddingBottom());
   int left = (getMeasuredWidth() - iconWidth) / 2;
   int top = (getMeasuredHeight() - (textBound.height() + iconWidth)) / 2;
   iconBound = new Rect(left, top, left + iconWidth, top + iconWidth);
 }
예제 #25
0
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    if (progressBackground != null) {

      final int width = progressBackground.getWidth() * mNumStars + (mNumStars - 1) * space;
      final int height = progressBackground.getHeight();
      setMeasuredDimension(
          resolveSizeAndState2(width, widthMeasureSpec, 0),
          resolveSizeAndState2(height, heightMeasureSpec, 0));
    }
  }
예제 #26
0
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

    width = getWidth();
    height = getHeight();

    // Log.d("tag",
    // "height="+width+"height="+height+"widthMeasureSpec="+widthMeasureSpec+"heightMeasureSpec="+heightMeasureSpec);
    if (width != 0 && height != 0) {
      initPoints(points);
    }
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  }
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   mPaintGradientTop.setShader(
       new LinearGradient(
           0,
           0,
           0,
           getMeasuredHeight() / 2,
           new int[] {Color.TRANSPARENT, colorGradientTop},
           new float[] {0, 1},
           Shader.TileMode.REPEAT));
 }
예제 #28
0
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    if (!isMeasured) {
      isMeasured = true;
      int viewHeight = getMeasuredHeight();
      int viewWidth = getMeasuredWidth();

      //            int mCanvasSize = 0;
      //            if (viewHeight < viewWidth) {
      //                mCanvasSize = viewHeight;
      //            }

      mWavePlaceY = viewWidth * mWaveFrontPlaceYRatio;
      // 波宽
      mWaveWidth = viewWidth * mWaveWidthRatio;
      // 波高 (振幅 x 2 = 波高)
      mWaveHeight = viewWidth * mWaveHeightRatio;
      // 需要的波形个数
      int n = Math.round(viewWidth / mWaveWidth) + 1;
      // n个波形需要4n+1个坐标点,因为需要做横向运动,左边需要预留一个波浪
      // 所以需要 4 * (n + 1) + 1 = 4 * n + 5 个点
      for (int i = 0; i < (4 * n + 6); i++) {
        float frontX = i * mWaveWidth / 4 - mWaveWidth;
        float y = 0;
        switch (i % 4) {
          case 0:
            y = mWavePlaceY;
            break;
          case 1:
            y = mWavePlaceY - mWaveHeight;
            break;
          case 2:
            y = mWavePlaceY;
            break;
          case 3:
            y = mWavePlaceY + mWaveHeight;
            break;
        }
        mFrontPointsList.add(new FloatPoint(frontX, y));

        // 因为左移后,后波浪在左边需要隐藏2个
        float backX = i * mWaveWidth / 4 - 2 * mWaveWidth;

        mBackPointsList.add(
            new FloatPoint(
                backX + mWaveWidth * mWaveBackPlaceXRatio, y - mWaveHeight * mWaveBackPlaceYRatio));
      }
    }
  }
예제 #29
0
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    // 得到绘制icon的宽
    int bitmapWidth =
        Math.min(
            getMeasuredWidth() - getPaddingLeft() - getPaddingRight(),
            getMeasuredHeight() - getPaddingTop() - getPaddingBottom() - mTextBound.height());

    int left = getMeasuredWidth() / 2 - bitmapWidth / 2;
    int top = (getMeasuredHeight() - mTextBound.height()) / 2 - bitmapWidth / 2;
    // 设置icon的绘制范围
    mIconRect = new Rect(left, top, left + bitmapWidth, top + bitmapWidth);
  }
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   int modeW = MeasureSpec.getMode(widthMeasureSpec);
   int width = MeasureSpec.getSize(widthMeasureSpec);
   int modeH = MeasureSpec.getMode(heightMeasureSpec);
   int height = MeasureSpec.getSize(heightMeasureSpec);
   if (modeW == MeasureSpec.UNSPECIFIED) {
     width = 250;
   }
   if (modeH == MeasureSpec.UNSPECIFIED) {
     height = 250;
   } // 当宽高不指定的时候,指定默认值
   setMeasuredDimension(width, height);
 }