Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Items within NestedScrollView need to be clicked twice after scrolling to top or bottom

Tags:

android

I have a NestedScrollView within a CoordinatorLayout. Within the NestedScrollView I have a LinearLayout with a few components, some of which are buttons. There are no customizations to the components, I only have the standard layout parameters.

The problem I'm facing is that whenever I fling the NestedScrollView to the top or to the bottom and see the overscroll edges, all buttons on the view do not handle any touch the first time they're pressed. A second touch is required and from then on any button will respond the first time. It's as if the focus gets lost and the first touch is to get it back to the view and the second one is the one that's really handled.

I've tried:

  1. Setting focusable=true, focusableInTouchMode=true and descendantFocusability=afterDescendants. Doesn't work.

  2. Overriding NestedScrollView's onScrollChanged to detect when we reach the top/bottom and manually request the focus for the closest view. Doesn't work, strange things happen, such as a view on the Toolbar getting focused...

  3. Simulating a touch event on the LinearLayout via dispatchTouchEvent().

None of them have worked. Many thanks in advance if you can help me see the light!

EDIT: seems to be related to this.

like image 600
Pin Avatar asked Sep 01 '15 17:09

Pin


1 Answers

Apparently this is a bug: https://code.google.com/p/android/issues/detail?id=178041

As of today, it's not fixed in the support library v23.

like image 102
Pin Avatar answered Oct 12 '22 01:10

Pin