I have a TextView
with many ClickableSpan
.
On click on a ClickableSpan
, I have to get the coordinate on screen of it (to show a custom View
at his position).
The problem is that I have no idea of how I can do this. The onClick()
method of the ClickableSpan
gives me in parameter a View
, the TextView
which contains the ClickableSpan
.
I have used the following to get characters position in the TextView
, but I don't know how I can convert it to get x/y position on screen of the text.
@Override
public void onClick(View v){
SpannableString completeText = (SpannableString)((TextView) v).getText();
Log.v("characters position", completeText.getSpanStart(this) + " / " + completeText.getSpanEnd(this));
}
Thanks in advance for your help!
EDIT : I want to get the entire coordinate of the ClickableSpan and its size, the aim is to show my custom view at the bottom center of the text. The onTouch method will give me the finger position, not the entire text coordinates. So, with this method, I will not have the middle of the text.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…