import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
public
class
Main extends Activity {
private
LinearLayout mLinearLayout;
@Override
public
void
onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(
new
StringView(
this
));
}
public
class
StringView extends View{
public
StringView(Context context){
super(context);
setBackgroundColor(Color.WHITE);
}
@Override
protected
void
onDraw(Canvas canvas) {
int
line = 30;
Paint paint =
new
Paint();
paint.setAntiAlias(
true
);
paint.setTextSize(12);
paint.setColor(0xFF000000);
canvas.drawText(
"window size :"
+getWidth()+
"x"
+getHeight(), 0, line, paint);
canvas.drawText(
"blank size :"
+(
int
)paint.measureText(
"AA"
), 0, line * 2, paint);
canvas.drawText(
"ascent :"
+(
int
)paint.ascent(), 0, line * 3, paint);
canvas.drawText(
"descent :"
+(
int
)paint.descent(), 0, line * 4, paint);
paint.setTextSize(10);
paint.setColor(Color.GRAY);
canvas.drawText(
"10dot - view"
, 0, line * 5, paint);
paint.setTextSize(12);
paint.setColor(0xFF000000);
canvas.drawText(
"12dot - view"
, 0, line * 6, paint);
paint.setTextSize(16);
paint.setColor(0xFF00FF00);
canvas.drawText(
"16dot - view"
, 0, line * 7, paint);
paint.setTextSize(24);
paint.setColor(0xFF0000FF);
canvas.drawText(
"24dot - view"
, 0, line * 8, paint);
paint.setColor(Color.GRAY);
canvas.drawText(
"GRAY"
, 0, line * 9, paint);
paint.setColor(Color.BLUE);
canvas.drawText(
"BLUE"
, (
int
)paint.measureText(
"BLUE"
) + 10, line * 9, paint);
paint.setColor(Color.CYAN);
canvas.drawText(
"CYAN"
, 0, line * 10, paint);
paint.setColor(Color.DKGRAY);
canvas.drawText(
"DKGRAY"
, (
int
)paint.measureText(
"DKGRAY"
) + 10, line * 10, paint);
paint.setColor(Color.GREEN);
canvas.drawText(
"GREEN"
, 0, line * 11, paint);
paint.setColor(Color.LTGRAY);
canvas.drawText(
"LTGRAY"
, (
int
)paint.measureText(
"LTGRAY"
) + 10, line * 11, paint);
paint.setColor(Color.MAGENTA);
canvas.drawText(
"MAGENTA"
, 0, line * 12, paint);
paint.setColor(Color.RED);
canvas.drawText(
"RED"
, (
int
)paint.measureText(
"MAGENTA"
) + 10, line * 12, paint);
paint.setColor(Color.YELLOW);
canvas.drawText(
"YELLOW"
, 0, line * 13, paint);
super.onDraw(canvas);
}
}
}