Search code examples
androidcanvasdrawtext

Read text from a location on canvas


I am trying to read text from a location on canvas in Android. I draw text at a specific location using drawtext and x, y co-ordinates. Now how can I read the text back from that location? Something like canvas.getText(x, y) etc.?


Solution

  • My advice would be to store an ArrayList of objects that contain your text and the coordinates. Then when you get the location you want to read from you just look it up in the ArrayList.

    Alternatively you could use a double array, and use the x and y coordinates as indices then store the text at that location in the array when you draw it.