Home » Android » android – Scroll doesn't work in NestedScrollView when try to scroll from views with click events

android – Scroll doesn't work in NestedScrollView when try to scroll from views with click events

Posted by: admin April 23, 2020 Leave a comment

Questions:

I’m using a NestedScrollView in a layout, and am attempting to use the new CoordinatorLayout from the design support library for CollapsingToolbarLayout.

My layout file looks like this:

When i try to scroll, sometimes it doesn’t work.
reason for this is, other elements of layout with click events are consuming the touch event.
Basically EditText, RadioButton, Button are consuming touch events.
Any Suggestions to solve this problem ?

How to&Answers:

I had the same problem. It happens only when NestedScrollView content height is less than height of device screen. So the workaround is to use setMinimumHeight(..) method for the view inside your NestedScrollView to make it resize to screen height:

where view is your RelativeLayout

It works fine fore me. Hope it helps you

Answer:

One of your ScrollViews will send all events to the first View that answer true on dispatchMotionEvent.

You may avoid using such scenario in your app OR override all dispatchMotionEvent methods (from scrolls and Views) to not consume the ACTION_DOWN.

Answer:

In your AndroidManifest.xml, make sure you have ‘windowSoftInputMode’ attribute set to ‘adjustResize’.

Answer:

The solution here (a workaround for this google issue by overriding the nestedScrollview) https://gist.github.com/chrisbanes/8391b5adb9ee42180893300850ed02f2 worked like a charm!

Define FixAppBarLayoutBehavior.java

Usage in java:

Usage in xml:

This is provided in the post Click not working on RecyclerView in CoordinatorLayout when scrolling.