1

I have a ScrollView with many views in it (TextView, Buttons, ...) and at the end there is an osmdroid-mapview, which is just a map. When I touch on the mapview, android does not move the map (zooming or changing the location of the map) but it moves the scrollview. For example, I move the finger up what means that the map should move south. But instead the scrollview moves down. My question is: Is it possible that the user can change the mapview and not the scrollview? Can I somehow block the mapview for scrolling interaction? But still the mapview has to be part of the scrollview.


<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <org.osmdroid.views.MapView
                    android:id="@+id/mapBbox"
                    android:layout_width="373dp"
                    android:layout_height="349dp"
                    android:layout_marginTop="40dp"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintHorizontal_bias="0.448"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/radioGroup" />

                ...
              
            </androidx.constraintlayout.widget.ConstraintLayout>
    </ScrollView>

    


KerryKilian
  • 95
  • 11
  • Perhaps you could create a layout similar to the Geopackage MapCache layout, which consists of a background MapView and a bottomsheet for managing other UI elements... https://github.com/ngageoint/geopackage-mapcache-android/blob/master/mapcache/src/main/res/layout/fragment_map.xml – ecle Aug 21 '22 at 02:44
  • There is also a "Map in a Scrollview" sample demo in the ***OsmDroid*** demo app, which can be found at https://play.google.com/store/apps/details?id=org.osmdroid. The sample source code for it in the demo app is available at https://github.com/osmdroid/osmdroid/blob/master/OpenStreetMapViewer/src/main/java/org/osmdroid/samplefragments/layouts/MapInScrollView.java. – ecle Oct 15 '22 at 13:01

1 Answers1

0

mapBbox.setNestedScrollingEnabled(false) see if you can use this inside your onCreate . What it does it it disables the scrolling behavior from the scrollview

Ps:

android:layout_width="373dp" << change to match parent 
android:layout_height="349dp" << change to wrap content or a seperate value
Narendra_Nath
  • 4,578
  • 3
  • 13
  • 31
  • I tried ```setNestedScrollingEnabled``` before, too. But it does not work. It just scrolls all the time when I touch the map. I also changed layout width and height. (Excuse me for my unknowing:) When I wrote wrap-content, the view had no size, so I decided to put the mapview into a new layout. Then ```wrap_content``` worked, but still not ```setNestedScrollingEnabled``` I am not sure what could cause the problem, but thanks for your help so far. – KerryKilian Aug 15 '22 at 18:13
  • can you try setting scrollview height to wrap_content – Narendra_Nath Aug 15 '22 at 18:18
  • I tried, but it does not work either – KerryKilian Aug 16 '22 at 11:04