Android calculate scrollTo position in HorizontalScrollView

后端 未结 1 1961
暗喜
暗喜 2021-01-06 09:57

I have HorizontalScrollView with few TextViews. Each TextView might contain text of different length.

How should I calculate correct offset to scroll to using \"scro

相关标签:
1条回答
  • 2021-01-06 10:33

    Try this:

    int x, y;
    x = myTextView.getLeft();
    y = myTextView.getTop();
    
    myHsv.scrollTo(x, y);
    

    getLeft() and getTop() should return the coordinates relative to the parent view (that is, the HorizontalScrollView in this instance.

    0 讨论(0)
提交回复
热议问题