2

I have two text views in a scrollView and I want to get their Y position when I tap them.

But I have tried many things in the debug console, always returning 0:

subView.getY()

subView.getScrollY()

What to do instead?

Thanks for your help.

Community
  • 1
  • 1
Rob
  • 4,123
  • 3
  • 33
  • 53

2 Answers2

6

Use getLocationOnScreen() method of view and pass int array and get 0 and 1 position for X and Y.

Godfather
  • 833
  • 9
  • 14
  • For those who need to know how to use this method : https://stackoverflow.com/a/2761184/14784590 – Reejesh Jan 12 '22 at 05:31
0

Use textView.getTop() and textView.getBottom()

fcdt
  • 2,371
  • 5
  • 14
  • 26