{"action":"created","issue":{"url":"https://api.github.com/repos/PPartisan/ScrollHandleExample/issues/2","repository_url":"https://api.github.com/repos/PPartisan/ScrollHandleExample","labels_url":"https://api.github.com/repos/PPartisan/ScrollHandleExample/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/PPartisan/ScrollHandleExample/issues/2/comments","events_url":"https://api.github.com/repos/PPartisan/ScrollHandleExample/issues/2/events","html_url":"https://github.com/PPartisan/ScrollHandleExample/issues/2","id":206454141,"number":2,"title":"Question: How to scroll to a view within the nestedScrollView ? ","user":{"login":"AndroidDeveloperLB","id":5357526,"avatar_url":"https://avatars.githubusercontent.com/u/5357526?v=3","gravatar_id":"","url":"https://api.github.com/users/AndroidDeveloperLB","html_url":"https://github.com/AndroidDeveloperLB","followers_url":"https://api.github.com/users/AndroidDeveloperLB/followers","following_url":"https://api.github.com/users/AndroidDeveloperLB/following{/other_user}","gists_url":"https://api.github.com/users/AndroidDeveloperLB/gists{/gist_id}","starred_url":"https://api.github.com/users/AndroidDeveloperLB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndroidDeveloperLB/subscriptions","organizations_url":"https://api.github.com/users/AndroidDeveloperLB/orgs","repos_url":"https://api.github.com/users/AndroidDeveloperLB/repos","events_url":"https://api.github.com/users/AndroidDeveloperLB/events{/privacy}","received_events_url":"https://api.github.com/users/AndroidDeveloperLB/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2017-02-09T09:52:33Z","updated_at":"2017-02-09T13:52:07Z","closed_at":null,"body":"Suppose I need to scroll to an inner view somewhere inside the nestedScrollView (including the resizing of the upper area, of course) , how do I do it? \r\nIt should work very similar to what this sample of the repo do it, but instead of scrolling in a number, scroll to a view.\r\nI want to know how to do it with and without the scrolling animation.\r\n\r\nI'm currently using this, but I'm not sure if that's the best way to do it:\r\n\r\n        final NestedScrollView nestedScrollView = ...\r\n        final View viewToScrollTo = ...\r\n        runJustBeforeBeingDrawn(viewToScrollTo, new Runnable() {\r\n            @Override\r\n            public void run() {\r\n                nestedScrollView.startNestedScroll(2);\r\n                final int top = viewToScrollTo.getTop();\r\n                nestedScrollView.setScrollY(top);\r\n                nestedScrollView.dispatchNestedPreScroll(0, top, null, null);\r\n                nestedScrollView.dispatchNestedScroll(0, 0, 0, top, null);\r\n                nestedScrollView.stopNestedScroll();\r\n            }\r\n        });\r\n\r\n    public static void runJustBeforeBeingDrawn(final View view, final Runnable runnable) {\r\n        final OnPreDrawListener preDrawListener = new OnPreDrawListener() {\r\n            @Override\r\n            public boolean onPreDraw() {\r\n                view.getViewTreeObserver().removeOnPreDrawListener(this);\r\n                runnable.run();\r\n                return true;\r\n            }\r\n        };\r\n        view.getViewTreeObserver().addOnPreDrawListener(preDrawListener);\r\n    }\r\n\r\nThe reason I think it's not a good solution, is that I don't think it scrolls to the correct position, because it seems to scroll so that the view to scroll to will be found around the middle, instead of the top. I don't know if it's even consistent when there are more view above and below the view to scroll to."},"comment":{"url":"https://api.github.com/repos/PPartisan/ScrollHandleExample/issues/comments/278645936","html_url":"https://github.com/PPartisan/ScrollHandleExample/issues/2#issuecomment-278645936","issue_url":"https://api.github.com/repos/PPartisan/ScrollHandleExample/issues/2","id":278645936,"user":{"login":"AndroidDeveloperLB","id":5357526,"avatar_url":"https://avatars.githubusercontent.com/u/5357526?v=3","gravatar_id":"","url":"https://api.github.com/users/AndroidDeveloperLB","html_url":"https://github.com/AndroidDeveloperLB","followers_url":"https://api.github.com/users/AndroidDeveloperLB/followers","following_url":"https://api.github.com/users/AndroidDeveloperLB/following{/other_user}","gists_url":"https://api.github.com/users/AndroidDeveloperLB/gists{/gist_id}","starred_url":"https://api.github.com/users/AndroidDeveloperLB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndroidDeveloperLB/subscriptions","organizations_url":"https://api.github.com/users/AndroidDeveloperLB/orgs","repos_url":"https://api.github.com/users/AndroidDeveloperLB/repos","events_url":"https://api.github.com/users/AndroidDeveloperLB/events{/privacy}","received_events_url":"https://api.github.com/users/AndroidDeveloperLB/received_events","type":"User","site_admin":false},"created_at":"2017-02-09T13:52:07Z","updated_at":"2017-02-09T13:52:07Z","body":"Will this work no matter how deep the view is inside the view hierarchy ? "}}
{"actor":{"display_login":"AndroidDeveloperLB"}}