Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/190.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在地图android中将布局膨胀为可绘制?_Android_Eclipse_Google Maps Api 2 - Fatal编程技术网

如何在地图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);