如何在地图android中将布局膨胀为可绘制?
我想在谷歌地图上显示我的布局作为标记,但它不能在地图上膨胀。谁能帮我解决这个问题。我使用北极星图书馆。我的代码写在下面:如何在地图android中将布局膨胀为可绘制?,android,eclipse,google-maps-api-2,Android,Eclipse,Google Maps Api 2,我想在谷歌地图上显示我的布局作为标记,但它不能在地图上膨胀。谁能帮我解决这个问题。我使用北极星图书馆。我的代码写在下面: final View altMarker = ((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE)) .inflate(R.layout.map_view, null); altMarker.setDrawingCacheEnabled(true);
final View altMarker = ((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE))
.inflate(R.layout.map_view, null);
altMarker.setDrawingCacheEnabled(true);
altMarker.buildDrawingCache();
@SuppressWarnings("deprecation")
Drawable drawable = new BitmapDrawable(altMarker.getDrawingCache());
final ArrayList<Annotation> annotations = new ArrayList<Annotation>();
for (Annotation[] region : sRegions) {
for (Annotation annotation : region) {
if (region == sFrance || region == sIndia) {
annotation.setMarker(drawable);
}
annotations.add(annotation);
}
}
final View altMarker=((LayoutInflater)getSystemService(Context.LAYOUT\u INFLATER\u SERVICE))
.充气(R.layout.map\u视图,空);
altMarker.setDrawingCacheEnabled(真);
altMarker.buildDrawingCache();
@抑制警告(“弃用”)
Drawable Drawable=新的BitmapDrawable(altMarker.getDrawingCache());
最终ArrayList注释=新ArrayList();
对于(注释[]区域:S区域){
用于(注释:区域){
if(region==sFrance | | region==sIndia){
注释.设置标记(可绘制);
}
注释。添加(注释);
}
}
试试这个:
Bitmap bitmap = Bitmap.createBitmap(altMarker.getWidth(), altMarker.getHeight(), Bitmap.Config.ARGB_4444);
Canvas canvas = new Canvas(bitmap);
view.draw(canvas);
Drawable drawable = new BitmapDrawable(bitmap);