I’m using osmdroid and osmdroid bonus pack to show balloons. Inside of balloons there are a scrollView which contains a linearlayout (vertical) as child.
When I try to scroll down, my mapview scroll too. How can I force the scroll action only to my balloon?
Answer
Ok, i found a solution, maybe it’s not the best solution, but it works for me like i expect
Create a class that extend from MapView and override the next methods:
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { float x = ev.getRawX(); float y = ev.getRawY(); View view = findViewById(R.id.my_overlay_view); if(view!=null){ boolean isInside = isPointInsideView(x, y, view); if(isInside){ System.out.println("Touch in"); canMove = false; }else{ int action = ev.getAction(); System.out.println(action); switch (action) { case MotionEvent.ACTION_MOVE: moving=true; break; case MotionEvent.ACTION_UP: if(!moving){ CustomDefaultInfoWindow window = (CustomDefaultInfoWindow)view.getTag(); window.close(); moving=false; } default: break; } canMove = true; } } return super.onInterceptTouchEvent(ev); } @Override public void scrollTo(int arg0, int arg1) { if(canMove){ super.scrollTo(arg0, arg1); } }; private boolean isPointInsideView(float x, float y, View view){ int location[] = new int[2]; view.getLocationOnScreen(location); int viewX = location[0]; int viewY = location[1]; //point is inside view bounds if(( x > viewX && x < (viewX + view.getWidth())) && ( y > viewY && y < (viewY + view.getHeight()))){ return true; } else { return false; } }