Mapbox NavigationView UI 将路线颜色的深色模式设置为红色

Mapbox NavigationView UI set Dark Mode with Route Color to Red

我已经实现了最新的 Mapbox 导航库 UI 如下。

implementation "com.mapbox.navigation:ui:1.5.1"
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.6.1'

Link 个文档:

我实现的:

XML:

<com.mapbox.navigation.ui.NavigationView
    android:id="@+id/navigationView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@id/ll_nav"
    mapbox:mapbox_cameraZoom="15" />

输出为:

我想要暗模式下路线方向为红色的地图。我尝试了很多旧库版本的解决方案,但我没有找到任何新版本的线索。我也尝试过实现 Style 但没有为 NavigationView.

工作

有人可以帮忙吗?

我认为您应该查看此 navigation style and guide link 以使用 Android 标准样式方式自定义它。 (与您在问题中分享的 link 相同。您只需要使用他们提供的 app:navigationDarkTheme 属性并继承他们的默认样式。

<com.mapbox.navigation.ui.NavigationView
        android:id="@+id/navigationView"
        app:navigationDarkTheme="@style/CustomNavigationViewDark"
        app:navigationLightTheme="@style/CustomNavigationViewDark"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/ll_nav"
        mapbox:mapbox_cameraZoom="15" />

CustomNavigationViewDark:

<style name="CustomNavigationViewDark" parent="MapboxStyleNavigationViewDark">
        <!-- The main turn banner view at the top of the screen -->
        <!-- Background color of the banner -->
        <item name="navigationViewBannerBackground">#FFFFFF</item>
        <!-- Color for the primary label that displays the turn name -->
        <item name="navigationViewBannerPrimaryText">#37516F</item>
        <!-- Color for the secondary label that occasionally appears underneath the primary label -->
        <item name="navigationViewBannerSecondaryText">#E637516F</item>
        <!-- Primary color for the turn arrow icons-->
        <item name="navigationViewBannerManeuverPrimary">#37516F</item>
        <!-- Secondary color for the turn arrow icons (e.g. the line segment that forks off) -->
        <item name="navigationViewBannerManeuverSecondary">#4D37516F</item>
        <!-- Alternate background color for the dropdown list of upcoming steps -->
        <item name="navigationViewListBackground">#FAFAFA</item>

        <!-- The summary view along the bottom of the screen -->
        <!-- Background color of the summary view -->
        <item name="navigationViewPrimary">@color/mapboxWhite</item>
        <!-- Tint color for icons in the summary view -->
        <item name="navigationViewSecondary">@color/mapboxBlue</item>
        <!-- Accent color for elements such as the recenter button -->
        <item name="navigationViewAccent">@color/mapboxPink</item>
        <!-- Color for the main duration label in the summary view -->
        <item name="navigationViewPrimaryText">#424242</item>
        <!-- Color for the secondary distance and ETA label in the summary view -->
        <item name="navigationViewSecondaryText">#424242</item>

        <!-- Custom colors for progress bars displayed during navigation -->
        <item name="navigationViewProgress">@color/red</item>
        <item name="navigationViewProgressBackground">@color/red</item>

        <!-- Custom colors for the route line and traffic -->
        <item name="navigationViewRouteStyle">@style/CustomNavigationMapRoute</item>

        <!-- Map style -->
        <item name="navigationViewMapStyle">mapbox://styles/bipinnt/ckp9cn6f10zyk17pk5gnxpelu</item>

        <!-- Other components -->
<!--        <item name="navigationViewDivider">#4882C6</item>-->
<!--        <item name="navigationViewRouteOverviewDrawable">#FAFAFA</item>-->
<!--        <item name="navigationViewDestinationMarker">@drawable/map_marker_light</item>-->
<!--        <item name="navigationViewLocationLayerStyle">@style/NavigationLocationLayerStyle</item>-->
    </style>

我希望这将解决您与自定义 NavigationView 相关的 issue/queries。