Guy*_*Guy 8 java android google-maps-markers google-maps-android-api-2
我刚开始使用Google Maps Utils库,因此我可以在其中添加带有文本的标记.到目前为止我理解了图书馆,并且我成功地使用了它.代码段:
IconGenerator icnGenerator = new IconGenerator(this);
Bitmap iconBitmap = icnGenerator.makeIcon(item.placeItemName);
myPlaceItemMarkers.add(mMap.addMarker(new MarkerOptions().position(new LatLng(item.latitude, item.longitude))
.icon(BitmapDescriptorFactory.fromBitmap(iconBitmap)).anchor(0.5f, 0.6f)));
Run Code Online (Sandbox Code Playgroud)
现在我开始玩一下窗口的样式,有两个特别感兴趣的功能:
icnGenerator.setBackground(Drawable background);
icnGenerator.setTextAppearance(int resid);
Run Code Online (Sandbox Code Playgroud)
我查找了有关文档的信息,而且只有不推荐使用的BubbleIconFactory信息.有人能告诉我如何使用这两个功能吗?我知道setTextAppearance用于更改文本样式但是我该怎么做?如果我没错,setBackground用于设置自定义标记背景,但我不知道如何使用它.
Guy*_*Guy 16
我仍然不完全确定如何使用setBackground()因为我尝试使用Drawables但它不起作用,但我想出了如何使用setTextAppearance().
我刚刚做了一个新的风格:
<style name="iconGenText">
<item name="android:textSize">14sp</item>
<item name="android:textColor">#000000</item>
</style>
Run Code Online (Sandbox Code Playgroud)
然后将其应用于IconGenerator:
IconGenerator icnGenerator = new IconGenerator(this);
icnGenerator.setTextAppearance(R.style.iconGenText);
Run Code Online (Sandbox Code Playgroud)
它的工作原理应该如此.
设置背景如下:
IconGenerator icnGenerator = new IconGenerator(this);
icnGenerator.setBackground(getResources().getDrawable(R.drawable.marker_background));
Run Code Online (Sandbox Code Playgroud)
marker_background必须是.9.png文件.就像图书馆的绘图一样.
它对我很有用.
| 归档时间: |
|
| 查看次数: |
7668 次 |
| 最近记录: |