如果您正在尋找繪製的MapView地圖視圖 可見rects內畫點什麼覆蓋像這些:
所以基本上你要做的是在畫布的幫助下將customImage強加在背景框上。使用此實現,您可以從畫布中有效地創建一個BitmapDrawable,然後您可以將其指定爲「ItemizedOverlay」的標記。如果這是您正在尋找的逐項疊加的類型,那麼就不需要重寫逐項疊加類的繪製函數。所有你需要做的就是使用下面的代碼來創建一個BitmapDrawable,你可以在它的構造函數中分配給你的ItemizedOverlay。下面是做到這一點的功能:
public BitmapDrawable imageOnDrawable(int drawableBackground, Bitmap customImage)
{
//The following line is optional but I'd advise you to minimize the size of
//the size of the bitmap (using a thumbnail) in order to improve draw
//performance of the overlays (especially if you are creating a lot of overlays).
Bitmap customImageThumbnail = ThumbnailUtils.extractThumbnail(
customImage, 100, 100);
Bitmap bm = BitmapFactory.decodeResource(getResources(), drawableId);
bm = Bitmap.createScaledBitmap(bm, 112, 120, false);
Canvas canvas = new Canvas(bm);
canvas.drawBitmap(bm, 0, 0, null);
// The 6,6 in the below line refer to the offset of the customImage/Thumbnail
// from the top-left corner of the background box (or whatever you want to use
// as your background)
canvas.drawBitmap(customImageThumbnail, 6, 6, null);
return new BitmapDrawable(bm);
}
問題不理解.Didü詳細解釋? – saravanan