简体   繁体   中英

Block Mapview from Scrollview interaction Android

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>

    


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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM