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

Android 画布的旋转

 2010-10-12 02:12:00 来源:本站整理   
核心提示:right-to-left* writing systems.**/public class LabelView extends View {private Paint mTextPaint;private String mText;private int mAscent;/*** Constructor. This
right-to-left

* writing systems.

*

*/

public class LabelView extends View {

private Paint mTextPaint;

private String mText;

private int mAscent;

/**

* Constructor. This version is only needed if you will be instantiating the

* object manually (not from a layout XML file).

*

* @param context

*/

public LabelView(Context context) {

super(context);

initLabelView();

}

/**

* Construct object, initializing with any attributes we understand from a

* layout file. These attributes are defined in

* SDK/assets/res/any/classes.xml.

*

* @see android.view.View#View(android.content.Context,

* android.util.AttributeSet)

*/

public LabelView(Context context, AttributeSet attrs) {

super(context, attrs);

initLabelView();

TypedArray a = context.obtainStyledAttributes(attrs,

R.styleable.LabelView);

CharSequence s = a.getString(R.styleable.LabelView_text);

if (s != null) {

setText(s.toString());

}

// Retrieve the color(s) to be used for this view and apply them.

// Note, if you only care about supporting a single color, that you

// can instead call a.getColor() and pass that to setTextColor().

setTextColor(a.getColor(R.styleable.LabelView_textColor, 0xFF000000));

int textSize = a.getDimensionPixelOffset(

R.styleable.LabelView_textSize, 0);

if (textSize > 0) {

setTextSize(textSize);

}

a.recycle();

}

private final void initLabelView() {

mTextPaint = new Paint();

mTextPaint.setAntiAlias(true);

mTextPaint.setTextSize(16);

上一页  1 2 3 4  下一页

Tags:Android 画布 旋转

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