1

我正在尝试在 textview 中获取文本的确切位置,当旋转为 0'、180'、360' 时,我通过此代码获得了文本在 textview 中的位置

fTranslationX 和 fTranslationY 是 MOtionEvent 的 event.getX 和 event.getY

    Rect rect = new Rect();
    rect.left = (int) fTranslationX;
    rect.top = (int) fTranslationY;
    rect.right = (int) (fTranslationX + getTextWidth());
    rect.bottom = (int) (fTranslationY + getLineHeight());

我的 TextView 是自定义的,所以旋转后我无法获得旋转的 Rect,我的文本被旋转但 Rect 保持在同一点!!如何在 TextView 中获取旋转文本的 Rect(TextView 的宽度 = 高度 = fill_parent)

任何想法?

4

0 回答 0