What I am trying to achieve is to scroll to scroll_position_1
when tab1
(and so on) is clicked like this. I don\'t understand what\'s happening at
You can use a ListView instead of a ConstraintLayout and add the text views to the list. Then, you can simply call listView.smoothScrollToPosition(index) instead of worrying about the x and y coordinates.
1) Edit your layout as shown below.
2) Add items to your ListView via code.
3) Upon tab click, call listView.smoothScrollToPosition(index_of_text_view) and your list view scrolls to that position.