android - placing a text value in a desired position -
i have drawn graphic object ,say rectangle. write text @ each corner of rectangle. how achieve ?
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); etc
if using canvas thenjust use drawtext() method.
drawtext(string text, int start, int end, float x, float y, paint paint) source: http://developer.android.com/reference/android/graphics/canvas.html
Comments
Post a Comment