开发者

Circling and selecting a text

开发者 https://www.devze.com 2023-02-02 10:05 出处:网络
I am developing an app in and i h开发者_Python百科ave a html page on the webView in android. that html page would have lots of lines of text, no images. when i circle a particular part ofthat text, th

I am developing an app in and i h开发者_Python百科ave a html page on the webView in android. that html page would have lots of lines of text, no images. when i circle a particular part of that text, the text within that circle should be highlighted and i need to find the co-ordinates of the circle. how do i do that in android. pls help me out.


This sounds like a pretty complex task...

I haven't done this myself but from the looks of the API you will probably want to use a GestureOverlay on top of the WebView. This will allow you to recognize gestures and get their coordinates. However recognizing just a circle or oval and not something else like a square or a squiggly line may require some more advanced mathematics. In the end I don't believe it is possible to select non-contiguous pieces of text so if your circle overlaps multiple lines of text but isn't the width of the entire screen I don't know what you would want to select.

One thing you could do is simulate a highlight by obtaining and sending a generated MotionEvent to the WebView's onTouchEvent method that starts at the top left of the circle gesture and ends and the bottom right. That would likely result in a highlight, but it may not be exactly what the user expects, especially if they did something weird like draw a really tall thin oval.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号