android mapview marker size
I need to add custom markers to a mapview. First question : is there a standard/default overlay/marker that I can use ? Second : if I've to create a png for the marker overlay, which is the best size for the image 开发者_如何学C? Do I have to create different images for each screen sizes (ldpi, mdpi, hdpi) ?
- Extend
ItemizedOverlay
and useOverlayItem
, where you can set you custom drawable viasetMarker(drawable)
. - Depends on your design. I personally used 32x32. You should give different sizes a try an see how they fit.
- Yes, this is preferable. You can use bitmap drawable, which can automatically resolve based on your screen size.
While there's a default drawable for the user's position, there really isn't anything suitable in the default android drawables for an overlay item. There are plenty of icon packs with the Google Maps API in mind on Deviant Art and Smashing Magazine to give you a boost.
Regarding your question about size, it is always best practise to provide multiple versions of icons to support different screen sizes and densities--especially if your app will have wide distribution and target a wide range of API levels.
Alternately, if you're worried about the physical screen real estate that your drawables take up, but don't feel like doing a lot of resizing manually, you can scale all your drawables on the fly when you detect screen density, based on a common scaling .xml file:From the Android Doco
Personally, I take the path of least resistance and provide three versions of every drawable I produce. Up to you, mate!
精彩评论