开发者

Android: using 9-patch and text for ItemizedOverlay on MapView

开发者 https://www.devze.com 2022-12-12 12:46 出处:网络
In my application I would like to mark different spots on a map. What I\'m now wondering is if there\'s a way to use a simple 9-p开发者_StackOverflowatch image and add the spot\'s name as text to it o

In my application I would like to mark different spots on a map. What I'm now wondering is if there's a way to use a simple 9-p开发者_StackOverflowatch image and add the spot's name as text to it or would I need to draw everything myself (including the text) in the draw() method of ItemizedOverlay?


As per this Q&A:

Drawing Nine Patch onto Canvas (Android)

you should be able to load the 9-patch using Resources.getDrawable, set the drawing bounds using Drawable.setBounds, and finally draw to the canvas provided in onDraw using Drawable.draw.

If you plan on reusing the drawable, you should keep an eye out for memory leaks, per this article.

0

精彩评论

暂无评论...
验证码 换一张
取 消