Reputation: 3
I am trying a navigation application demo. I use a button,a mapview and a navigation view same layout. When layout created, mapview init for getting destination point and drawing route from current location. Then when clicked on the start button, The navigationview is starting to navigate. The scenario is working fine.
But have a problem, when navigationview started to navigate, mapview view didn't go. Just map view is staying navigation view.
I added screenshots.
My Layout xml code:
<Button
android:id="@+id/button_Navigate"
android:layout_width="410dp"
android:layout_height="63dp"
android:layout_marginStart="144dp"
android:layout_marginTop="36dp"
android:text="Start Navigate"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.cardview.widget.CardView
android:id="@+id/card_viewMap"
android:layout_width="500dp"
android:layout_height="500dp"
android:layout_marginTop="148dp"
android:layout_marginEnd="60dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
card_view:cardCornerRadius="0dp">
<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
mapbox:mapbox_cameraZoom="17"></com.mapbox.mapboxsdk.maps.MapView>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/card_viewNavigate"
android:layout_width="1000dp"
android:layout_height="500dp"
android:layout_marginTop="148dp"
android:layout_marginEnd="60dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
card_view:cardCornerRadius="0dp">
<com.mapbox.services.android.navigation.ui.v5.NavigationView
android:id="@+id/navigationView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"></com.mapbox.services.android.navigation.ui.v5.NavigationView>
</androidx.cardview.widget.CardView>
And I tried everything about setVisibility(View.INVISIBLE) or bringtoFront() functions but same problem.
Upvotes: 0
Views: 218
Reputation: 2718
Cover your
<androidx.cardview.widget.CardView
android:id="@+id/card_viewMap"
android:layout_width="500dp"
android:layout_height="500dp"
android:layout_marginTop="148dp"
android:layout_marginEnd="60dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
card_view:cardCornerRadius="0dp">
<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
mapbox:mapbox_cameraZoom="17"></com.mapbox.mapboxsdk.maps.MapView>
</androidx.cardview.widget.CardView>
With a FrameLayout.
Changes:
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:id="@+id/card_viewMap"
android:layout_width="500dp"
android:layout_height="500dp"
android:layout_marginTop="148dp"
android:layout_marginEnd="60dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
card_view:cardCornerRadius="0dp">
<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
mapbox:mapbox_cameraZoom="17"></com.mapbox.mapboxsdk.maps.MapView>
</androidx.cardview.widget.CardView>
</FrameLayout>
Upvotes: 0