我繪製了一個圖形對象,例如矩形。我想在矩形的每個角落寫一些文字。如何實現這一目標?將文本值放置在所需的位置
private static class SimpleView extends View {
private ShapeDrawable mDrawable = new ShapeDrawable();
public SimpleView(Context context) {
super(context);
setFocusable(true);
this.mDrawable = new ShapeDrawable(new RectShape());
this.mDrawable.getPaint().setColor(0xFF0F00FF);
}
@Override
protected void onDraw(Canvas canvas) {
int x1 = 50;
int y1 = 150;
int width = 400;
int height = 50;
this.mDrawable.setBounds(x1, y1, x1 + width, y1 + height);
this.mDrawable.draw(canvas);
int x = 0;
int y = 0;
Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL);
等
PLZ,提供了一個例子。 – Macarse 2011-04-11 13:04:32
你使用什麼組件,畫布? – 2011-04-11 13:05:05
是的,我正在使用畫布 – m4n07 2011-04-11 13:06:37