2016-03-01 121 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); 
} 
相關問題