2013-05-21 82 views
0

我想在谷歌地圖上顯示我的佈局作爲標記,但它不能在地圖上膨脹。任何人都可以幫助我解決這個問題。我使用polaris庫。我的代碼如下記載:如何在地圖android中繪製可膨脹的佈局?

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

回答

0

試試這個:

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