找到一个角色的坐标?

Uwa*_*s A 2 android textview coordinates

我有一个多线TextView.有没有办法让像素的x坐标到达字符的左边,例如第3个字符?在我的情况下,它将始终是第3个字符,但一般的解决方案会更好.

我使用的字符正上方的像素的y坐标:

Layout textViewLay = mTextView.getLayout();
int posY = textViewLay.getLineTop(0);
Run Code Online (Sandbox Code Playgroud)

但是x坐标让我很难过.有任何想法吗?我可能错过了一些非常简单的东西.

Cuo*_*ynh 5

尝试使用此代码:

Rect bounds = new Rect();
Paint tpaint = textView.getPaint();
tpaint.getTextBounds(text,0,2,bounds);
int height = bounds.height();
int width = bounds.width();
Run Code Online (Sandbox Code Playgroud)