Draw Text Example
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Path.Direction;
import android.os.Bundle;
import android.view.View;
public class DrawTextActivity extends Activity {
String abc = "Hi hello welcome to android apps development ";
Paint mPaint, tPaint;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new GraphicView(this));
mPaint = new Paint();
tPaint = new Paint();
mPaint.setColor(0xFFFFFF00);
tPaint.setColor(Color.MAGENTA);
tPaint.setTextSize(20);
tPaint.setStrokeWidth(6);
}
public class GraphicView extends View{
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Path circle = new Path();
circle.addCircle(150, 150, 100, Direction.CW);
canvas.drawPath(circle, mPaint);
canvas.drawTextOnPath(abc, circle, 0, 20, tPaint);
}
public GraphicView(Context context) {
super(context);
}
}
}
No comments:
Post a Comment