2

现在我使用此代码显示了默认的矩形形状。

 this.infoWindow = (ViewGroup)getLayoutInflater().inflate(R.layout.newcustomdialog, null);
 this.infoImage=(ImageView)infoWindow.findViewById(R.id.graphicimage);
 this.infoTitle = (TextView)infoWindow.findViewById(R.id.balloon_item_title);
 this.infoSnippet = (TextView)infoWindow.findViewById(R.id.balloon_item_snippet);
 this.close=(Button)infoWindow.findViewById(R.id.close_img_button);
 this.infoButton = (Button)infoWindow.findViewById(R.id.more);
     //
   // Setting custom OnTouchListener which deals with the pressed state
   // so it shows up 
 this.infoButtonListener = new OnInfoWindowElemTouchListener(HomeScreen.this,infoButton) 
 {
       @Override
       protected void onClickConfirmed(View v, Marker marker) {
          // v.setVisibility(View.GONE);
           // Here we can perform some action triggered after clicking the button
        Toast.makeText(HomeScreen.this, marker.getTitle() + "'s button clicked!", Toast.LENGTH_SHORT).show();
       }

 }; 
   //oraii 
 this.exitButtonListener=new OnInfoWindowExitListener(HomeScreen.this,infoWindow) {

    @Override
    protected void onClickConfirmed(View v, Marker marker) {
        // TODO Auto-generated method stub

    }
 };

 this.infoButton.setOnTouchListener(infoButtonListener);
 this.close.setOnTouchListener(exitButtonListener);      

 map.setInfoWindowAdapter(new InfoWindowAdapter() {
       public View getInfoWindow(Marker marker) {
           return null;
       }

       public View getInfoContents(Marker marker) {
           // Setting up the infoWindow with current's marker info
        StringTokenizer st2 = new StringTokenizer(marker.getTitle(), ",");

           String imageurl="";
           String title="";
          String eventid="";
           while (st2.hasMoreElements()) {
                eventid=st2.nextElement().toString();
                imageurl=st2.nextElement().toString();
                title=st2.nextElement().toString();
            }
           EventId=eventid;
           infoTitle.setText(title);
           infoSnippet.setText(marker.getSnippet());
           imageLoader.DisplayImage(imageurl,HomeScreen.this, infoImage);
           infoButtonListener.setMarker(marker);
           exitButtonListener.setMarker(marker);

           // We must call this to set the current marker and infoWindow references
           // to the MapWrapperLayout 
           mapWrapperLayout.setMarkerWithInfoWindow(marker, infoWindow);
           return infoWindow;
       }
   });

我想将形状更改为心形意味着自定义形状,如图表对话框形状..如何做到这一点..如果有人知道,请帮助我。 现在我变得这样了

4

1 回答 1

16

custom_infowindow.xml

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout 
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="110dp"
  android:layout_height="110dp"
  android:orientation="vertical"
  android:background="@drawable/heart"
  android:gravity="center"
   >

<RelativeLayout
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 >

 <Button 
     android:layout_width="40dp"
     android:layout_height="20dp"
     android:layout_alignParentTop="true"
     android:layout_marginLeft="60dp"
     android:layout_marginTop="15dp"
     android:text="Click!"
     android:textColor="#ffffff"
     android:textSize="10dp"
     android:background="#373737"/>  

<TextView
 android:layout_width="wrap_content"
 android:layout_height="wrap_content" 
 android:text="HELLO"
 android:textColor="#FF0000"
 android:padding="10dp"
 android:layout_centerInParent="true"
 android:background="#00000000" 
 />

 </RelativeLayout>

</LinearLayout>

这是您的心形布局..复制并粘贴到应用程序的可拖动文件夹中...lolz 检查这个 下载

只需将上面的视图膨胀到自定义信息窗口..!

mMap.setInfoWindowAdapter(new InfoWindowAdapter() {

    public View getInfoWindow(Marker arg0) {
        View v = getLayoutInflater().inflate(R.layout.custom_infowindow, null);
        return v;
    }

    public View getInfoContents(Marker arg0) {

        //View v = getLayoutInflater().inflate(R.layout.custom_infowindow, null);

        return null;

    }
});

这只是我创建的图像..您可以添加比我更好的图像...如果可行,请告诉我...:)

于 2013-05-23T11:21:38.480 回答