android - Find exact coordinates of a single Character inside a TextView -


currently i'm using paintobject.measuretext(textcopy.substring(0,i)) while iterating through copy of textview's text. example, measuretext("abc".substring(0,1)) give me relative x coordinates of 'b'. y coordinate layout.getlinetop(). working not accurate x coordinates non-monospaced fonts. can calibrate little, on each device works differently.

the best solution can think of overwrite class responsible drawing textview on screen and, hopefully, coordinates of each character drawn screen.

does know class need overwrite accomplish this? or maybe other creative solution?

well seems sort of bug of paint.measuretext() or other deeper class. have finally found way around it:

layout.getprimaryhorizontal(int offset) 

this easy. iterate through layout using length of text uses.

it return the x of character regardless of line position. lines i'm still getting layout.getlinetop(). way, if using layout.getlinetop(), note there strange behaviour, possibly bug. have submitted bug report here.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -