Issue
I am trying to use a MapActivity
inside a ScrollView
page. When I run the app to test it, the map cant be clicked correctly because as the user tries to swipe on the map the scrollview takes over and kinda makes it hard to swipe on it.
Here is how it looks(Map included at the very bottom):
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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=".CreateAds.FurnitureAd.CreateFunP1Fragment">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/lll"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="@string/ad_title"
android:inputType="textPersonName"
android:textColor="@color/colorPrimary"
tools:layout_editor_absoluteX="182dp"
tools:layout_editor_absoluteY="16dp"
android:importantForAutofill="no" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/rrr"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="@+id/lll"
app:layout_constraintStart_toStartOf="@+id/lll"
app:layout_constraintTop_toBottomOf="@+id/lll">
<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ems="10"
android:hint="@string/offer_price"
android:inputType="number"
android:textColor="@color/colorPrimary"
android:importantForAutofill="no" />
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:id="@+id/textView16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/currency"
android:textColor="@color/colorPrimary"
app:layout_constraintStart_toStartOf="@+id/spinner2"
app:layout_constraintTop_toBottomOf="@+id/rrr" />
<Spinner
android:id="@+id/spinner2"
style="@style/Widget.AppCompat.Spinner.Underlined"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="@+id/rrr"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/rrr"
app:layout_constraintTop_toBottomOf="@+id/textView16" />
<TextView
android:id="@+id/textView18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/state"
android:textColor="@color/colorPrimary"
app:layout_constraintStart_toStartOf="@+id/spinner2"
app:layout_constraintTop_toBottomOf="@+id/spinner2" />
<Spinner
android:id="@+id/spinner3"
style="@style/Widget.AppCompat.Spinner.Underlined"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="@+id/spinner2"
app:layout_constraintStart_toStartOf="@+id/spinner2"
app:layout_constraintTop_toBottomOf="@+id/textView18" />
<TextView
android:id="@+id/textView20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/city"
android:textColor="@color/colorPrimary"
app:layout_constraintStart_toStartOf="@+id/spinner3"
app:layout_constraintTop_toBottomOf="@+id/spinner3" />
<Spinner
android:id="@+id/spinner4"
style="@style/Widget.AppCompat.Spinner.Underlined"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="@+id/spinner3"
app:layout_constraintStart_toStartOf="@+id/spinner3"
app:layout_constraintTop_toBottomOf="@+id/textView20" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="@+id/spinner4"
app:layout_constraintStart_toStartOf="@+id/spinner4"
app:layout_constraintTop_toBottomOf="@+id/spinner4">
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="@string/location"
android:inputType="text"
android:importantForAutofill="no" />
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:id="@+id/textView24"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/map"
android:textColor="@color/colorPrimary"
app:layout_constraintStart_toStartOf="@+id/textInputLayout"
app:layout_constraintTop_toBottomOf="@+id/textInputLayout" />
<include
layout="@layout/activity_maps"
android:layout_width="0dp"
android:layout_height="450dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView24" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
Is implementing it like this wrong?
Solution
What we did on this scenario was first to add some margin/padding to the map so that the user could scroll on its side.
But then we decided it was better to set that map in the ScrollView not interactive and set an invisible button on the top of it and when the user taps on the button a new activity opened with the map maximised. And there is no scroll in that new activity, the user can only interact with the map or go back.
The fragment which loaded the map was the same, so the code for the map was shared, it's just placed in two different layouts (inside the scrollview without interaction enabled and in the new activity).
Answered By - jeprubio
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.