// Viewを継承したクラスのメソッド
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
Paint rubyPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
Paint textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
rubyPaint.setTextSize(12.0f);
textPaint.setTextSize(24.0f);
rubyPaint.setColor(Color.WHITE);
textPaint.setColor(Color.WHITE);
String ruby = "シリアライズ";
String text = "serialize";
float rubyX = (textPaint.measureText(text) - rubyPaint.measureText(ruby)) / 2;
float textX = 0.0f;
float rubyY = 32.0f;
float textY = rubyY + textPaint.getTextSize();
canvas.drawText(ruby, rubyX, rubyY, rubyPaint);
canvas.drawText(text, textX, textY, textPaint);
canvas.drawColor(Color.TRANSPARENT);
}
Sabtu, 04 Desember 2010
Viewで文字列を描画
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar