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

Android 画布的旋转

 2010-10-12 02:12:00 来源:本站整理   
核心提示:mTextPaint.setColor(0xFF000000);setPadding(3, 3, 3, 3);}/*** Sets the text to display in this label** @param text* The text to display. This will be drawn as on

mTextPaint.setColor(0xFF000000);

setPadding(3, 3, 3, 3);

}

/**

* Sets the text to display in this label

*

* @param text

* The text to display. This will be drawn as one line.

*/

public void setText(String text) {

mText = text;

requestLayout();

invalidate();

}

/**

* Sets the text size for this label

*

* @param size

* Font size

*/

public void setTextSize(int size) {

mTextPaint.setTextSize(size);

requestLayout();

invalidate();

}

/**

* Sets the text color for this label.

*

* @param color

* ARGB value for the text

*/

public void setTextColor(int color) {

mTextPaint.setColor(color);

invalidate();

}

/**

* @see android.view.View#measure(int, int)

*/

@Override

protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

setMeasuredDimension(measureWidth(widthMeasureSpec),

measureHeight(heightMeasureSpec));

}

/**

* Determines the width of this view

*

* @param measureSpec

* A measureSpec packed into an int

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

*/

private int measureWidth(int measureSpec) {

int result = 0;

int specMode = MeasureSpec.getMode(measureSpec);

int specSize = MeasureSpec.getSize(measureSpec);

if (specMode == MeasureSpec.EXACTLY) {

// We were told how big to be

result = specSize;

} else {

// Measure the text

result = (int) mTextPaint.measureText(mText) + getPaddingLeft()

上一页  1 2 3 4  下一页

Tags:Android 画布 旋转

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