因此,我正尝试使用mapbox mapView向我的Android应用添加一个小型迷你地图。我正在尝试添加圆角,但似乎找不到找到这种方法的方法。有什么好方法吗?我知道一种选择是使用CardView,但似乎并没有绕过地图的角落。
答案 0 :(得分:1)
<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>
此卡应该最适合您。
答案 1 :(得分:0)
使用XML的Mapbox地图的布局宽度和高度是什么?
我关注了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>
答案 2 :(得分:0)
这是Mapbox与后台AR视图结合使用的问题。对我有用的是在地图中启用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>