@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // TODO Auto-generated method stub int measuredHeight = measureHeight(heightMeasureSpec); int measuredWidth = measureHeight(widthMeasureSpec); rectheight = (measuredHeight - 1) / line; setTextSize(rectheight / 2); super.setMeasuredDimension(measuredWidth, measuredHeight); }
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); width = MeasureSpec.getSize(widthMeasureSpec); height = MeasureSpec.getSize(heightMeasureSpec); // make sure widget remain in a good appearance if ((float) height / (float) width < 0.33333F) { height = (int) ((float) width * 0.33333F); widthMeasureSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.getMode(widthMeasureSpec)); heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.getMode(heightMeasureSpec)); super.setMeasuredDimension(widthMeasureSpec, heightMeasureSpec); } centerX = width / 2; centerY = height / 2; cornerRadius = centerY - shadowSpace; innerContentBound.left = outerStrokeWidth + shadowSpace; innerContentBound.top = outerStrokeWidth + shadowSpace; innerContentBound.right = width - outerStrokeWidth - shadowSpace; innerContentBound.bottom = height - outerStrokeWidth - shadowSpace; intrinsicInnerWidth = innerContentBound.width(); intrinsicInnerHeight = innerContentBound.height(); knobBound.left = outerStrokeWidth + shadowSpace; knobBound.top = outerStrokeWidth + shadowSpace; knobBound.right = height - outerStrokeWidth - shadowSpace; knobBound.bottom = height - outerStrokeWidth - shadowSpace; intrinsicKnobWidth = knobBound.height(); knobMaxExpandWidth = (float) width * 0.7F; if (knobMaxExpandWidth > knobBound.width() * 1.25F) { knobMaxExpandWidth = knobBound.width() * 1.25F; } }