[英]Icon on top of another icon in Android
我正在编写一个类似地图的 android 应用程序(使用 java),我使用 Google Maps SKD 中的两种标记:一种用于我当前的位置,另一种表示我感兴趣的地方。
我为这些标记设置了两个不同的图标,我怎样才能给其中一个优先级? 我希望 mu 当前位置图标标记显示在所有其他图标标记上,我该怎么做?
谢谢你的时间:)
编辑:这是我用于当前位置标记的一些代码
Drawable arrowDrawable = getResources().getDrawable(R.drawable.current_position_icon);
BitmapDescriptor arrowIcon = getMarkerIconFromDrawable(arrowDrawable);
Marker currentPositionMarker = gMap.addMarker(new MarkerOptions()
.position(new LatLng(location.getLatitude(), location.getLongitude()))
.draggable(false)
.rotation(location.getBearing())
.icon(arrowIcon)
.flat(true));
这是我用来设置其他标记的一些代码
Marker marker = gMap.addMarker(new MarkerOptions()
.position(new LatLng(event.getLatitude(), event.getLongitude()))
.title("Acc. value -> " + Double.toString(event.getAccelerometerValue()))
.icon(potholeIcon)
.draggable(false));
这是我唯一一次使用我的标记,我不在我的 XML 或其他 Java 代码中使用它。
在渲染所有其他图标后渲染您的“当前位置图标”。
如果它是 XML,那么最后添加它。
如果它在 Java 中,那么只需最后声明并将其添加到布局中。
如果您无法提供代码,则无法提供代码...
编辑:
下定决心,我会提供一些代码。
XML:
<Layout...>
<Other_Icon.../>
<Other_Icon.../>
<Other_Icon.../>
<Your_Current_Position.../>
</Layout...>
或者
爪哇:
Layout layout=new Layout(...);
//A lot of other icons...
layout.addView(icon1);
layout.addView(icon2);
layout.addView(icon3);
//Your position icon...
layout.addView(your_current_position_icon);
或者,如果您使用拖放。
只需将图标放在最后。
(但如果你编码它只是为了确保它会更好。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.