WEB开发网
开发学院手机开发Android 开发 Android 画布的旋转 阅读

Android 画布的旋转

 2010-10-12 02:12:00 来源:本站整理   
核心提示:+ getPaddingRight();if (specMode == MeasureSpec.AT_MOST) {// Respect AT_MOST value if that was what is called for by// measureSpecresult = Math.min(result, spec

+ getPaddingRight();

if (specMode == MeasureSpec.AT_MOST) {

// Respect AT_MOST value if that was what is called for by

// measureSpec

result = Math.min(result, specSize);

}

}

return result;

}

/**

* Determines the height of this view

*

* @param measureSpec

* A measureSpec packed into an int

* @return The height of the view, honoring constraints from measureSpec

*/

private int measureHeight(int measureSpec) {

int result = 0;

int specMode = MeasureSpec.getMode(measureSpec);

int specSize = MeasureSpec.getSize(measureSpec);

mAscent = (int) mTextPaint.ascent();

if (specMode == MeasureSpec.EXACTLY) {

// We were told how big to be

result = specSize;

} else {

// Measure the text (beware: ascent is a negative number)

result = (int) (-mAscent + mTextPaint.descent()) + getPaddingTop()

+ getPaddingBottom();

if (specMode == MeasureSpec.AT_MOST) {

// Respect AT_MOST value if that was what is called for by

// measureSpec

result = Math.min(result, specSize);

}

}

return result;

}

/**

* Render the text

*

* @see android.view.View#onDraw(android.graphics.Canvas)

*/

@Override

protected void onDraw(Canvas canvas) {

super.onDraw(canvas);

// not rotate

// canvas.drawText(mText, 200, 500, mTextPaint);

// rotate 90

canvas.rotate(90);

canvas.drawText(mText, 500, -200, mTextPaint);

// rotate -90

// canvas.rotate(-90);

// canvas.drawText(mText, -500, 200, mTextPaint);

}

}

上一页  1 2 3 4 

Tags:Android 画布 旋转

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接