开发者

Trouble getting height of OverlayItem Drawable

开发者 https://www.devze.com 2022-12-24 00:23 出处:网络
I\'m having some trouble getting a hold of the drawable a certain OverlayItem is using so I can calculate the height of it and properly offset the note that shows onTap. Here is my code to try to get

I'm having some trouble getting a hold of the drawable a certain OverlayItem is using so I can calculate the height of it and properly offset the note that shows onTap. Here is my code to try to get that drawable:

Drawable marker = item.getMarker(android.R.attr.state_focused);
if (marker != null) int markerHeight = marker.getIntrinsicHeight();

marker ends up null.

I'm using a drawable XML file with a selector开发者_如何学C for the different states of the OverlayItem's drawable. In it I'm specifying a drawable for the null state, state_focused, and state_pressed.

Thanks for any help!

-Nick


According to the documentation about getMarker:

Returns the marker that should be used when drawing this item on the map. A null value means that the default marker should be drawn.

Therefore all you need to do is to pre-calculate the height of the default marker, store it somewhere and return it in case null is returned.

I have also find this discussion about OverlayItem and ItemizedOverlay useful.

0

精彩评论

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