All docsNavigation SDK for AndroidExamplesShow customized status messages

Show customized status messages

Note

This example is a part of the Navigation SDK Examples. You can find the values for all referenced resources in the res directory. For example, see res/values/strings.xml for R.string.* references used in this example.

mapbox_activity_show_custom_status.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.mapbox.maps.MapView
android:id="@+id/mapView"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
tools:background="#00ccff" />
<com.mapbox.navigation.ui.status.view.MapboxStatusView
style="@style/MapboxCustomStatusView"
android:id="@+id/statusView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:scaleX="1"
tools:scaleY="1"/>
</androidx.constraintlayout.widget.ConstraintLayout>
ShowCustomStatusActivity.kt
styles_status.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MapboxCustomStatusView" parent="MapboxStyleStatusView">
<item name="android:elevation">0dp</item>
<item name="android:background">#673AB7</item>
<item name="android:scaleX">0</item>
<item name="android:scaleY">0</item>
<item name="android:padding">10dp</item>
<item name="statusViewShowAnimator">@animator/scale_in</item>
<item name="statusViewHideAnimator">@animator/scale_out</item>
<item name="statusViewProgressBarTint">#ffffff</item>
<item name="statusViewIconTint">#ffffff</item>
<item name="statusViewTextAppearance">@style/MapboxCustomStatusView.TextAppearance</item>
</style>
<style name="MapboxCustomStatusView.TextAppearance">
<item name="android:textColor">#ffffff</item>
<item name="android:textSize">16sp</item>
<item name="android:fontFamily">cursive</item>
<item name="android:textStyle">bold</item>
<item name="android:textAllCaps">true</item>
</style>
</resources>