gpt4 book ai didi

java - Android OverlayItem.setMarker() : Change the marker for one item

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:02:53 25 4
gpt4 key购买 nike

尝试更改覆盖项目的标记时,我注意到 setMarker() 使该项目不可见。这是代码示例。

//Create new marker
Drawable icon = this.getResources().getDrawable(R.drawable.marker);

//Set the new marker to the overlay
overlayItem.setMarker(icon);

最佳答案

需要为Drawable指定一个边界矩形:

//Create new marker
Drawable icon = this.getResources().getDrawable(R.drawable.marker);

//Set the bounding for the drawable
icon.setBounds(
0 - icon.getIntrinsicWidth() / 2, 0 - icon.getIntrinsicHeight(),
icon.getIntrinsicWidth() / 2, 0);

//Set the new marker to the overlay
overlayItem.setMarker(icon);

关于java - Android OverlayItem.setMarker() : Change the marker for one item,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7505574/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com