1

When I am using CoordinatorLayout, I just want to nested scroll view state or please give me an suggestion for how to suddenly stop scrolling..

Because I am using scrollTo() function it's not working properly, when override the scrolling. So I want to stop previous scrolling then call scrollTo() function.

My code is :

  scrollView.post(new Runnable() {
        @Override
        public void run() {
            scrollView.scrollTo(0, contentHeadingView.getTop());
        }
    });

And any idea to get NestedScrollView scrolling action is stopped and NestedScrollView scrolling action is start. It will more help full for me.

Please help me.

I hope you someone to give me a solution.

Thanks.

Mathan Chinna
  • 587
  • 6
  • 22

2 Answers2

2

To stop scrolling simply use scrollView.smoothScrollBy(0, 0);

kalabalik
  • 3,792
  • 2
  • 21
  • 50
  • thanks, scrolling will be stopped but after using `scrollTo()` is not working properly.. – Mathan Chinna Jan 17 '18 at 10:56
  • Can you please be more specific? And also explain what you mean by "I just want to nested scroll view". – kalabalik Jan 17 '18 at 11:08
  • ok , i want to navigate some specific view inside the nested scroll view. so i am using `scrollTo()` function when its working correctly on call this function, after after scrolling normally then again call the same function it's not working properly that mean's it's not navigate to mentioned view. – Mathan Chinna Jan 17 '18 at 11:19
  • What does it do instead of scrolling to a specific view? What does `contentHeadingView.getTop()` give you? – kalabalik Jan 17 '18 at 11:26
  • `contentHeadingView` is nothing it's `LinearLayout view`. When i am click heading navigation button to call that function. – Mathan Chinna Jan 17 '18 at 11:40
  • you have any idea to get NestedScrollView scrolling action is stopped and NestedScrollView scrolling action is start. It will more help full for me. – Mathan Chinna Jan 17 '18 at 11:46
  • You still failed to explain what you want and what your code actually does. So tell me: WHERE do you want to scroll to? Why do you think `contentHeadingView.getTop()` gives you a value (not "nothing", right?) which is useful for achieving that goal? And what does it actually return? And didn't we agree that we already have found a way to stop scrolling and that we now have to find a way to scroll to ..., well, tell me. – kalabalik Jan 17 '18 at 12:06
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/163324/discussion-between-mathan-chinna-and-kalabalik). – Mathan Chinna Jan 17 '18 at 12:10
0

To stop scrolling you need to use this method nestedScrollView.stopNestedScroll(); and then to start scrolling to certain position use this method nestedScrollView.scrollTo(0,0); If you want to start scroll after sometime, you can use this inside handler. Hope this works!

devjava20
  • 3
  • 3