I want to get x,y co-ordinate array of displaying text on screen.
i have to get whole co-ordinate of "this string".
I have 2 option to display text:
1.Draw text in canvas-> when i am doing text on canvas using canvas.drawText(). then how to get all x,y co-ordinate to drawing text .i have to get top,bottom,left,right position.but can't get all co-ordinate of Drawing text. please give me solution to getting whole x,y co-ordinate arraylist.
2.Set Text in View(for ex,button,textview,edittext etc)-> i m doing settext() of view.but can't getting x,y co-ordinate array of whole displaying text.
I am draw this string using below code:
public class DrawCanvas extends View {
public DrawCanvas (Context mContext) {
super(mContext);
}
public void onDraw(Canvas canvas) {
clipBounds_canvas = canvas.getClipBounds();
String str = "णमो अरिहंताणं";
paint.setColor(Color.WHITE);
paint.setStyle(Paint.Style.FILL);
canvas.drawPaint(paint);
paint.setTextAlign(Paint.Align.CENTER);
paint.setColor(Color.BLACK);
int scaledSize = (int) getResources().getDimensionPixelSize(R.dimen.myFontSize);
int fontSize = scaledSize;
paint.setTextSize(fontSize);
Log.e("tag", "canvas.getWidth()" + canvas.getWidth());
int xPos = (canvas.getWidth() / 2);
int yPos = (int) ((canvas.getHeight() / 2));
paint.setAntiAlias(true);
canvas.drawText(str, xPos, yPos, paint);
canvas.drawPath(drawPath, paint);
}
}
i want to get all x,y pixel when draw this string.....