2016-03-01 87 views

回答

47

目前,我认为我们无法改变标志的大小,所以美国可以在绘制并重新添加标记图像-size是这样的:,

int height = 100; 
int width = 100; 
BitmapDrawable bitmapdraw=(BitmapDrawable)getResources().getDrawable(R.mipmap.marker); 
    Bitmap b=bitmapdraw.getBitmap(); 
Bitmap smallMarker = Bitmap.createScaledBitmap(b, width, height, false); 

乌尔添加标记是这样使用图标

   map.addMarker(new MarkerOptions() 
         .position(POSITION) 
         .title("Your title") 
         .icon(BitmapDescriptorFactory.fromBitmap(smallMarker)) 
       ); 
+2

感谢的人!!!!!!! –

0

我认为你可以在this question上寻找答案,它已经解释了如何通过创建动态动态位图来创建具有给定宽度和高度的自定义标记。

0

[编辑:格式化]

Drawable circleDrawable = getResources().getDrawable(R.mipmap.primarysplitter); 
      bitmapDescriptor=getMarkerIconFromDrawable(circleDrawable); 


private BitmapDescriptor getMarkerIconFromDrawable(Drawable drawable) { 
    Canvas canvas = new Canvas(); 
    Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); 
    canvas.setBitmap(bitmap); 
    drawable.setBounds(0, 0, (int)getResources().getDimension(R.dimen._30sdp), (int)getResources().getDimension(R.dimen._30sdp)); 
    drawable.draw(canvas); 
    return BitmapDescriptorFactory.fromBitmap(bitmap); 
} 
相关问题