【问题标题】:how to inflate layout as drawable in map android?如何在地图android中将布局膨胀为可绘制?
【发布时间】:2013-05-21 09:51:12
【问题描述】:

我想将我的布局显示为谷歌地图上的标记,但它不能在地图上膨胀。谁能帮我解决这个问题。我使用北极星图书馆。我的代码写在下面:

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);
            }
        }

【问题讨论】:

    标签: android eclipse google-maps-api-2


    【解决方案1】:

    试试这个:

    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);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-22
      • 1970-01-01
      • 1970-01-01
      • 2015-11-23
      相关资源
      最近更新 更多