Search code examples
androidandroid-mapviewscrollviewandroid-scrollview

Android - ScrollView and MapView in same layout breaks ScrollView


I have a layout which has a ScrollView and a MapView as pretty much sibling elements in the XML, with some buttons at the bottom of the screen that do alpha animations to cross fade between them.

Both the views start with the android:visibility="invisible". If the ScrollView is faded in first, it works just fine. However once I cross fade to the MapView, then back to the ScrollView, the ScrollView is now broken - it doesn't scroll it just sits there.

It's as if once the MapView appears on the scene it takes over all gesture detection in that part of the screen real estate.

I'm really at a loss here, I've tried a dozen different things, but nothing is working.


Solution

  • OK, I fixed this myself by subclassing the MapView and adding a simple, boolean isActive property. Then override the onTouchEvent method so that if (isActive) { return super.onTouchEvent(ev); } else { return false; }