使用android的地图覆盖中带边框的图像

使用android的地图覆盖中带边框的图像,android,map,overlay,Android,Map,Overlay,我显示了这个链接,但答案只是显示气球 但我发现就像带边框的显示图像一样。。。。这样地。 如果有人知道怎么做,请帮助我 我已完成在地图中显示3-5幅图像。但现在我只想显示带有边框的图像 提前感谢。您需要创建这样的图像 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:lay

我显示了这个链接,但答案只是显示气球

但我发现就像带边框的显示图像一样。。。。这样地。

如果有人知道怎么做,请帮助我

我已完成在地图中显示3-5幅图像。但现在我只想显示带有边框的图像


提前感谢。

您需要创建这样的图像

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:orientation="horizontal" 
    android:paddingBottom="5dip"
    android:paddingLeft="5dip" 

    android:id="@+id/balloon_main_layout"
    android:background="@drawable/popupbg"
    android:paddingTop="0dip"
    >
<ImageView android:layout_width="40dp"
        android:layout_height="40dp" 

        android:id="@+id/diseaseImg" 
        android:padding="5dp"
        android:layout_gravity="center_vertical"
        ></ImageView>
    <LinearLayout 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:orientation="vertical" 
        android:layout_weight="1"
        android:paddingTop="10dip" 
        android:paddingRight="30dip"
        android:id="@+id/balloon_inner_layout">
        <TextView android:layout_height="wrap_content"
            android:layout_width="wrap_content" 
            android:id="@+id/balloon_item_title"
            android:text="balloon_item_title" 
            android:layout_marginLeft="2dp"
            android:textSize="14dip"
            android:paddingBottom="5dp"
            android:textColor="#FF000000"></TextView>

    </LinearLayout>

    <ImageView android:layout_width="30dp"
        android:layout_height="30dp" 
        android:src="@android:drawable/ic_menu_close_clear_cancel"
        android:id="@+id/close_img_button" 
        android:layout_gravity="right"
        android:paddingLeft="10dip"
        android:paddingBottom="10dip" 
        android:paddingRight="8dip"
        android:paddingTop="2dip"></ImageView>

</LinearLayout>

这是9补丁的图片

现在需要创建自定义布局来处理此问题,并创建自定义布局文件以显示引出序号

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:orientation="horizontal" 
    android:paddingBottom="35dip"
    android:paddingLeft="10dip"  
    android:id="@+id/balloon_main_layout"
    android:background="@drawable/balloon_overlay_bg_selector" 
    android:paddingTop="0dip"
    android:paddingRight="0dip">
       <ImageView android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:src="@drawable/your_default_image"
        android:id="@+id/img_button" 
        android:paddingLeft="10dip"
        android:paddingBottom="10dip" 
        android:paddingRight="8dip"
        android:paddingTop="8dip"></ImageView>
</LinearLayout>


现在,您可以创建这种类型的图像并将其设置为布局背景,然后在该图像视图中根据需要显示不同的图像

您需要这样创建图像

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:orientation="horizontal" 
    android:paddingBottom="5dip"
    android:paddingLeft="5dip" 

    android:id="@+id/balloon_main_layout"
    android:background="@drawable/popupbg"
    android:paddingTop="0dip"
    >
<ImageView android:layout_width="40dp"
        android:layout_height="40dp" 

        android:id="@+id/diseaseImg" 
        android:padding="5dp"
        android:layout_gravity="center_vertical"
        ></ImageView>
    <LinearLayout 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:orientation="vertical" 
        android:layout_weight="1"
        android:paddingTop="10dip" 
        android:paddingRight="30dip"
        android:id="@+id/balloon_inner_layout">
        <TextView android:layout_height="wrap_content"
            android:layout_width="wrap_content" 
            android:id="@+id/balloon_item_title"
            android:text="balloon_item_title" 
            android:layout_marginLeft="2dp"
            android:textSize="14dip"
            android:paddingBottom="5dp"
            android:textColor="#FF000000"></TextView>

    </LinearLayout>

    <ImageView android:layout_width="30dp"
        android:layout_height="30dp" 
        android:src="@android:drawable/ic_menu_close_clear_cancel"
        android:id="@+id/close_img_button" 
        android:layout_gravity="right"
        android:paddingLeft="10dip"
        android:paddingBottom="10dip" 
        android:paddingRight="8dip"
        android:paddingTop="2dip"></ImageView>

</LinearLayout>

这是9补丁的图片

现在需要创建自定义布局来处理此问题,并创建自定义布局文件以显示引出序号

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:orientation="horizontal" 
    android:paddingBottom="35dip"
    android:paddingLeft="10dip"  
    android:id="@+id/balloon_main_layout"
    android:background="@drawable/balloon_overlay_bg_selector" 
    android:paddingTop="0dip"
    android:paddingRight="0dip">
       <ImageView android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:src="@drawable/your_default_image"
        android:id="@+id/img_button" 
        android:paddingLeft="10dip"
        android:paddingBottom="10dip" 
        android:paddingRight="8dip"
        android:paddingTop="8dip"></ImageView>
</LinearLayout>


现在,您可以创建这种类型的图像并将其设置为布局背景,然后在该图像视图中根据需要显示不同的图像

private class ProximityOverlay extends Overlay {

    public void draw(Canvas canvas, MapView mapview, boolean b) {
        // draw some stuff in here, like
        Paint paint = new Paint();
        paint.setAntiAlias(true);
        paint.setStrokeWidth(2.0f);
        double latitude = location.getLatitude();
        double longitude = location.getLongitude();
        Projection projection = mapView.getProjection();
        GeoPoint leftGeo = new GeoPoint((int) (latitude * 1e6),
                (int) (longitude * 1e6));
        Point left = new Point();
        projection.toPixels(leftGeo, left);

        paint.setColor(Color.parseColor("#00CCFF"));
        paint.setStyle(Style.FILL);
        canvas.drawCircle(left.x, left.y, 9, paint);
        paint.setColor(Color.parseColor("#003399"));
        paint.setStyle(Style.STROKE);
        canvas.drawCircle(left.x, left.y, 10, paint);



    }
您可以修改它以绘制黑色矩形:

canvas.drawRect(left, top, right, bottom, paint);

下面是一些绘制圆的代码:

private class ProximityOverlay extends Overlay {

    public void draw(Canvas canvas, MapView mapview, boolean b) {
        // draw some stuff in here, like
        Paint paint = new Paint();
        paint.setAntiAlias(true);
        paint.setStrokeWidth(2.0f);
        double latitude = location.getLatitude();
        double longitude = location.getLongitude();
        Projection projection = mapView.getProjection();
        GeoPoint leftGeo = new GeoPoint((int) (latitude * 1e6),
                (int) (longitude * 1e6));
        Point left = new Point();
        projection.toPixels(leftGeo, left);

        paint.setColor(Color.parseColor("#00CCFF"));
        paint.setStyle(Style.FILL);
        canvas.drawCircle(left.x, left.y, 9, paint);
        paint.setColor(Color.parseColor("#003399"));
        paint.setStyle(Style.STROKE);
        canvas.drawCircle(left.x, left.y, 10, paint);



    }
您可以修改它以绘制黑色矩形:

canvas.drawRect(left, top, right, bottom, paint);

按照中的建议创建一个类BalloodItemizeOverlay

并创建您想要显示的xml覆盖(例如,我创建了这样的覆盖)

此类具有methode setImage(字符串项)

其中字符串包含图像的URL


使用图像url路径在HelloItemized overlay的onTap方法中调用此方法创建一个类BalloodItemizeOverlay,如中所建议

并创建您想要显示的xml覆盖(例如,我创建了这样的覆盖)

此类具有methode setImage(字符串项)

其中字符串包含图像的URL

在带有图像url路径的HelloItemized覆盖的onTap方法中调用此方法