Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MapView inside a ScrollView?

I would like to have a MapView inside a ScrollView, however when I try to scroll the map, the ScrollView takes priority! Is there a way to give the MapView priority when scrolling inside the map, and the ScrollView otherwise?

Thanks!

like image 790
Cesar Avatar asked Jul 01 '11 09:07

Cesar


People also ask

How many views can you use within a ScrollView?

ScrollView is a subclass of FrameLayout , which means that you can place only one View as a child within it; that child contains the entire contents to scroll.

What is the difference between NestedScrollView and ScrollView?

NestedScrollView is just like ScrollView , but it supports acting as both a nested scrolling parent and child on both new and old versions of Android. Nested scrolling is enabled by default.

Is ScrollView a layout?

In Android, a ScrollView is a view group that is used to make vertically scrollable views. A scroll view contains a single direct child only. In order to place multiple views in the scroll view, one needs to make a view group(like LinearLayout) as a direct child and then we can define many views inside it.

Which one is an attribute of ScrollView?

ScrollView is used to scroll the child elements of palette inside ScrollView. Android supports vertical scroll view as default scroll view. Vertical ScrollView scrolls elements vertically. Android uses HorizontalScrollView for horizontal ScrollView.


1 Answers

I have had a same problem for 10 days, but I got a solution a few minutes ago!! Here is the solution. I made a custom MapView and override onTouchEvent() like this.

@Override public boolean onTouchEvent(MotionEvent ev) {     int action = ev.getAction();     switch (action) {     case MotionEvent.ACTION_DOWN:         // Disallow ScrollView to intercept touch events.         this.getParent().requestDisallowInterceptTouchEvent(true);         break;      case MotionEvent.ACTION_UP:         // Allow ScrollView to intercept touch events.         this.getParent().requestDisallowInterceptTouchEvent(false);         break;     }      // Handle MapView's touch events.     super.onTouchEvent(ev);     return true; } 
like image 159
Emily Sooryum Avatar answered Sep 23 '22 18:09

Emily Sooryum