我正在制作一个应用程序,可以在某些点添加地图.我希望我的针脚的颜色与我们的应用程序的主题颜色相匹配.对不起,我真的是个菜鸟
int color = Color.rgb(255,201,14); mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap(); final LatLng PERTH = new LatLng(40,-80); Marker perth = mMap.addMarker(new MarkerOptions() .position(PERTH) .title("MY PIN") .snippet("MAGGIE EATS SNAKE SKINS") .draggable(true) .icon(BitmapDescriptorFactory.fromresource(R.drawable.pin)) .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.color)));
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.color)));不起作用.它不允许我在这里插入自定义颜色.我怎样才能做到这一点?谢谢:)
解决方法
defaultMarker()方法允许设置自定义颜色,但只能通过提供色调值.根据android文档:
(Hue) Value must be greater or equal to 0 and less than 360
如果您知道应用主题的十六进制或RGB值,则需要进行一些计算(请参阅example)或仅使用一些free online converter.在您的情况下,色调值将为47.
此外,您无需在代码中设置两次.icon()属性.