0

I have a bunch of view in ScrollView. Some of them are TextInputEditText. When an error occurs I use setError for particular TextInputEditText. And I have such effect. enter image description here

But my layout is long, and I need to scroll to view with an error. Code:

protected void showInputError(TextInputEditText edtText, @StringRes int resId) {
    edtText.setError(getString(resId));
    scrollView.post(() -> {
        scrollView.scrollTo(0, edtText.getTop());
    });
}

All works fine first time. But the app does the same scrolling after any other scrolling. I mean,

  1. set an error to view
  2. scroll programmatically to this view
  3. scroll manually to another place. Application scrolls again to view from step 2.

The main problem: Application scrolls back to view when user scrolls manually (after applying of scrollTo)

Please, give a hint how to overcome this

  • Possible duplicate of [Scroll to a specific view in scroll view](https://stackoverflow.com/questions/21483188/scroll-to-a-specific-view-in-scroll-view) – krishank Tripathi Mar 16 '18 at 10:52
  • @krishankTripathi I know how to scroll in code. But the main problem is that "Application scrolls back to view when user scrolls manually (after applying of scrollTo)" – Дмитро Яковлєв Mar 16 '18 at 11:22

0 Answers0