java - Canvas.drawText not drawing in exact position -


this gist of android app does:
1. user selects picture gallery or default pictures in app
2. picture displayed in imageview
3. user clicks anywhere on picture
4. user types text , clicks 'done' button
5. text drawn on bitmap using canvas.drawtext

the problem: text not drawn user clicks. noticed problem occurs pictures bigger can fit in imageview.

this code retrieves coordinates user clicked:

mimageview.setontouchlistener(new ontouchlistener() {  @override public boolean ontouch(view v, motionevent event) { // todo auto-generated method stub  if (event.getactionmasked() == motionevent.action_up) {     xcoord = event.getx();     ycoord = event.gety();     medittext.settext("");  toast.maketext(getapplicationcontext(), xcoord + ", " + ycoord, toast.length_long).show();  }  return true; }     }); 

and code draws text on bitmap:

string text = medittext.gettext().tostring();  paint textpaint = new textpaint(paint.anti_alias_flag); textpaint.setcolor(colorid); textpaint.settextsize(textsize); textpaint.setantialias(true);  bitmap mutable = mbitmap.copy(bitmap.config.argb_8888, true); canvas canvas = new canvas(mutable);              canvas.drawtext(text, xcoord, ycoord, textpaint); mimageview.setimagebitmap(mutable); mbitmap = mutable;  medittext.settext(""); 

i using 720x1280, 320 dpi emulator.
appreciated! in advance!


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -