簡體   English   中英

圓角地圖框 mapView

[英]Rounded corner mapbox mapView

因此,我正在嘗試使用 mapbox mapView 向我的 android 應用程序添加一個小型迷你地圖。 我試圖給它添加圓角,但我似乎找不到辦法做到這一點。 有沒有好的方法可以做到這一點? 我知道一種選擇是使用 CardView,但它似乎沒有繞過地圖的角落。

<android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="400dp"
    app:cardCornerRadius="12dp"
    app:cardElevation="12dp">

    Put your mapview in here

</android.support.v7.widget.CardView>

這張卡應該非常適合你。

這是 Mapbox 與后台 AR 視圖相結合的問題。 對我renderTextureMode是在地圖中啟用renderTextureMode

嘗試這個:

<!-- CardView for rounded corners -->
<androidx.cardview.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
                                   android:id="@+id/map_container"
                                   android:layout_width="200dp"
                                   android:layout_height="200dp"
                                   android:layout_gravity="center"
                                   card_view:cardCornerRadius="100dp"
                                   android:layout_alignParentBottom="true"
                                   android:layout_alignParentRight="true"
                                   android:layout_marginRight="16dp"
                                   android:layout_marginBottom="16dp"
                                   tools:ignore="RtlHardcoded">
    <com.mapbox.mapboxsdk.maps.MapView
            android:id="@+id/mapView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:mapbox_cameraTargetLat="40.73581"
            app:mapbox_cameraTargetLng="-73.99155"
            app:mapbox_cameraZoom="11"
            app:mapbox_renderTextureMode="true"/>
</androidx.cardview.widget.CardView>

您的 Mapbox 地圖在 XML 中的布局寬度和高度是多少?

我關注了https://developer.android.com/guide/topics/ui/layout/cardview ,這個 XML 對我有用

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<!-- A CardView that contains a TextView -->
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:id="@+id/card_view"
    android:layout_width="200dp"
    android:layout_height="200dp"
    android:layout_gravity="center"
    android:layout_marginTop="32dp"
    card_view:cardCornerRadius="10dp"
    card_view:layout_constraintEnd_toEndOf="parent"
    card_view:layout_constraintStart_toStartOf="parent"
    card_view:layout_constraintTop_toTopOf="parent">

    <com.mapbox.mapboxsdk.maps.MapView
        android:id="@+id/mapView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        mapbox:mapbox_cameraTargetLat="40.73581"
        mapbox:mapbox_cameraTargetLng="-73.99155"
        mapbox:mapbox_cameraZoom="11"
        mapbox:mapbox_styleUrl="mapbox://styles/mapbox/streets-v10" />

</android.support.v7.widget.CardView>


</android.support.constraint.ConstraintLayout>

圓角 Mapbox MapView

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM