Reputation: 614
I Have a NestedScrollView
which it has some elements like textView
,recyclerView
etc. in itself .
The Problem is When i call smoothScrollTo(x,y) for first time , everything is OK .
But second call of smoothScrollTo(x,y) will change the scroll position again in a random position.
Here is the code :
public void linkToComments(View view) {
int[] pos = {0, 0};
commentsCountText.getLocationOnScreen(pos);
scrollView.fling(0);
scrollView.smoothScrollTo(pos[0], pos[1]);
}
whats the problem ?
Upvotes: 0
Views: 574
Reputation: 134
I think this may solve your problem
public void linkToComments(View view) {
scrollView.fling(0);
scrollView.smoothScrollTo(0, commentsCountText.getBottom());
}
Upvotes: 0