私は図形オブジェクト、例えば矩形を描いています。私は長方形の各隅にテキストを書きたいと思います。これを達成する方法は?希望する位置にテキスト値を配置する
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
Canvasはどのコンポーネントを使用していますか? –
はいキャンバスを使用しています – m4n07