2

I have a fullscreen TextView with a very long text, ie. like a story with say 400 lines.

I would like to be able to drop icons into the TextView, then insert some text in the position where the icon was dropped.

For example, i drop the icon at the coordinates 400,1700 and that corresponds to the word 'especialmente' at the string position 597 (see screenshot)

I have the DnD thing done, however, I don't know how to calculate the indexOf of the TextView from the droped coordinates.

enter image description here

Is there a simple way to do it ? Or this will get that complex so as to create StaticLayout's and a ton of math?

rupps
  • 9,712
  • 4
  • 55
  • 95
  • Spannable string might address some of your concerns. Better use it as a starting point. – Illegal Argument Aug 07 '14 at 03:06
  • I already use spannable strings for indentation, links, format and for inserting images into the text, but I don't see how can I use it to calculate the substring from a pixel position, can you please be more specific? – rupps Aug 07 '14 at 07:24
  • Found the answer here http://stackoverflow.com/questions/2302867/android-how-to-determine-character-index-of-a-touch-events-position-in-textvie :) – rupps Aug 07 '14 at 07:33

0 Answers0