1

I want to color the letter I click on in a TextView, so to get the offset I use

getOffsetForPosition(event.getX(), event.getY());

You can clearly see in the image below I click on 'o' in Genymotion (also on Galaxy S4). Why does it say I click on 'h'?

What can be the problem?

[1]

Ran
  • 657
  • 2
  • 13
  • 29
  • have you tried doing `getOffsetForPosition(x,y)-1`? I think its following the same behaviour as when you tap on a edittext and the cursor appears on the next letter. – wanpanman Jul 02 '16 at 14:50
  • Just reverses the problem... If at the begging clicking in the middle of letter 1 colored letter 2, now to click in the middle of letter 2 colors letter 1... If only it was possible to decrease by 0.5... – Ran Jul 02 '16 at 15:01
  • 1
    How about this solution? http://stackoverflow.com/questions/2302867/android-how-to-determine-character-index-of-a-touch-events-position-in-textvie – wanpanman Jul 02 '16 at 15:12
  • 1
    getTextBounds didn't help but measureText seems to be good! Now I need to test this to see if there are hidden problems. – Ran Jul 02 '16 at 15:41

0 Answers0