@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); }
@Override protected void onMeasure(int widthSpec, int heightSpec) { int fourThreeHeight = makeMeasureSpec(getSize(widthSpec) * 3 / 4, EXACTLY); super.onMeasure(widthSpec, fourThreeHeight); }
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { heightMeasureSpec = MeasureSpec.makeMeasureSpec(mMeasureTarget.getMeasuredHeight(), MeasureSpec.EXACTLY); super.onMeasure(widthMeasureSpec, heightMeasureSpec); } }
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); final View thisView = this; final int width = thisView.getMeasuredWidth(); final int height = thisView.getMeasuredHeight(); mScaleX = 1f * width / WIDTH; mScaleY = 1f * (mViewportHeight > 0 ? mViewportHeight : height) / HEIGHT; updateMountainPath(mMoveFactor, height); updateTreePath(mMoveFactor, true); }
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); setMeasuredDimension(CIRCLE_SPACING * mImageCount, CIRCLE_SPACING); }
/** * {@inheritDoc} */ @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); parentWidth = MeasureSpec.getSize(widthMeasureSpec); parentHeight = MeasureSpec.getSize(heightMeasureSpec); setMeasuredDimension(parentWidth, parentHeight); }
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int width = View.MeasureSpec.getSize(widthMeasureSpec); int height = View.MeasureSpec.getSize(heightMeasureSpec); int widthMode = View.MeasureSpec.getMode(widthMeasureSpec); int heightMode = View.MeasureSpec.getMode(heightMeasureSpec); if (height <= 0 && width <= 0 && heightMode == View.MeasureSpec.UNSPECIFIED && widthMode == View.MeasureSpec.UNSPECIFIED) { width = 0; height = 0; } else if (height <= 0 && heightMode == View.MeasureSpec.UNSPECIFIED) { height = (int) (width * aspectRatioHeight / aspectRatioWidth); } else if (width <= 0 && widthMode == View.MeasureSpec.UNSPECIFIED) { width = (int) (height * aspectRatioWidth / aspectRatioHeight); } else if (width * aspectRatioHeight > aspectRatioWidth * height) { width = (int) (height * aspectRatioWidth / aspectRatioHeight); } else { height = (int) (width * aspectRatioHeight / aspectRatioWidth); } super.onMeasure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)); }
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); if (getMeasuredWidth() > maxWidth || getMeasuredHeight() > maxHeight) { if (getMeasuredWidth() > maxWidth) widthMeasureSpec = MeasureSpec.makeMeasureSpec(maxWidth, MeasureSpec.EXACTLY); if (getMeasuredHeight() > maxHeight) heightMeasureSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.EXACTLY); super.onMeasure(widthMeasureSpec, heightMeasureSpec); } }
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); mWidth = getMeasuredWidth(); mHeight = getMeasuredHeight(); radius = Math.min(mWidth / 2, mHeight / 2); }
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); Log.i(TAG_NAME,"onMeasure"); int width = defaultStepIndicatorNum; mHeight = 0; if(mStepNum > 0) { //dynamic measure VerticalStepViewIndicator height mHeight = (int) (getPaddingTop() + getPaddingBottom() + mCircleRadius * 2 * mStepNum + (mStepNum - 1) * mLinePadding); } if(MeasureSpec.UNSPECIFIED != MeasureSpec.getMode(widthMeasureSpec)) { width = Math.min(width, MeasureSpec.getSize(widthMeasureSpec)); } setMeasuredDimension(width, mHeight); }
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); int widthSize = getWidthSize(widthMeasureSpec); int heightSize = getHeightSize(heightMeasureSpec); setMeasuredDimension(widthSize, heightSize); }
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); int allPadding = _adjustText(getMeasuredWidth()); int fontLen = mIsChecked ? mFontLenChecked : mFontLen; // 如果为精确测量 MeasureSpec.EXACTLY,则直接使用测量的大小,否则让控件实现自适应 // 如果你用了精确测量则 mHorizontalPadding 和 mVerticalPadding 会对最终大小判定无效 int width = (MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY) ? MeasureSpec.getSize(widthMeasureSpec) : allPadding + fontLen; int height = (MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.EXACTLY) ? MeasureSpec.getSize(heightMeasureSpec) : mVerticalPadding * 2 + mFontH; setMeasuredDimension(width, height); // 计算图标放置位置 if (mDecorateIcon != null || mDecorateIconChange != null) { int top = (height - mIconSize) / 2; int left; if (mIconGravity == Gravity.RIGHT) { int padding = (width - mIconSize - fontLen - mIconPadding) / 2; left = width - padding - mIconSize; } else { left = (width - mIconSize - fontLen - mIconPadding) / 2; } if (mTagMode == MODE_ICON_CHECK_CHANGE && mIsChecked && mDecorateIconChange != null) { mDecorateIconChange.setBounds(left, top, mIconSize + left, mIconSize + top); } else if (mDecorateIcon != null) { mDecorateIcon.setBounds(left, top, mIconSize + left, mIconSize + top); } } }
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); int widthSpecMode = MeasureSpec.getMode(widthMeasureSpec); int widthSpecSize = MeasureSpec.getSize(widthMeasureSpec); int heightSpecMode = MeasureSpec.getMode(heightMeasureSpec); int heightSpecSize = MeasureSpec.getSize(heightMeasureSpec); int width = (int) dp2px(CIRCLE_DIAMETER); int height = (int) dp2px(CIRCLE_DIAMETER); if (widthSpecMode == MeasureSpec.AT_MOST && heightSpecMode == MeasureSpec.AT_MOST) { setMeasuredDimension(width, height); } else if (widthSpecMode == MeasureSpec.AT_MOST) { setMeasuredDimension(width, heightSpecSize); } else if (heightSpecMode == MeasureSpec.AT_MOST) { setMeasuredDimension(widthSpecSize, height); } }
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); if (orientation == HORIZONTAL) { setMeasuredDimension(getMeasuredWidth(), getContext().getResources().getDimensionPixelSize(R.dimen.carbon_dividerHeight)); } else { setMeasuredDimension(getContext().getResources().getDimensionPixelSize(R.dimen.carbon_dividerHeight), getMeasuredHeight()); } } }
@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; if (widthMode == MeasureSpec.EXACTLY) { width = widthSize; } else if (widthMode == MeasureSpec.AT_MOST) { width = Math.min(viewWidth, widthSize); } else { width = viewWidth; } if (heightMode == MeasureSpec.EXACTLY || widthMode == MeasureSpec.EXACTLY) { height = heightSize; } else if (heightMode == MeasureSpec.AT_MOST) { height = Math.min(viewHeight, heightSize); } else { height = viewHeight; } setMeasuredDimension(width, height); }
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); if (id != 0) { android.widget.TextView textView = ((ViewGroup) getParent()).findViewById(id); if (text == null) text = textView.getText(); paint = textView.getPaint(); if (layout == null) layout = new StaticLayout(text, paint, getMeasuredWidth(), Layout.Alignment.ALIGN_NORMAL, 1, 0, true); String firstLine = text.subSequence(0, layout.getLineEnd(0)).toString(); paint.getTextBounds(firstLine, 0, firstLine.length(), rect); baseline = Math.abs(rect.top); rect.top = -layout.getLineAscent(0) + rect.top; String lastLine = text.subSequence(layout.getLineStart(layout.getLineCount() - 1), layout.getLineEnd(layout.getLineCount() - 1)).toString(); paint.getTextBounds(lastLine, 0, lastLine.length(), rect2); rect.bottom = layout.getHeight() - layout.getLineDescent(layout.getLineCount() - 1) + rect2.bottom; setMeasuredDimension(getMeasuredWidth(), rect.height() + getPaddingTop() + getPaddingBottom()); } }
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); int width = getMeasuredWidth(); int height = getMeasuredHeight(); int widthWithoutPadding = width - getPaddingLeft() - getPaddingRight(); int heigthWithoutPadding = height - getPaddingTop() - getPaddingBottom(); int maxWidth = (int) (heigthWithoutPadding * RATIO); int maxHeight = (int) (widthWithoutPadding / RATIO); if (widthWithoutPadding > maxWidth) { width = maxWidth + getPaddingLeft() + getPaddingRight(); } else { height = maxHeight + getPaddingTop() + getPaddingBottom(); } setMeasuredDimension(width, height); }
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); isometric.measure(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.getSize(heightMeasureSpec), sort, cull, boundsCheck); }
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int height = mDrawable.getIntrinsicHeight() + getPaddingTop() + getPaddingBottom(); heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY); super.onMeasure(widthMeasureSpec, heightMeasureSpec); }
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); setMeasuredDimension(measureWidthSize(widthMeasureSpec), measureHeightSize(heightMeasureSpec)); }