2

now i displayed the default rectangle shape using this code.

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

i want to change the shape to heart shape means custom shape like a chart dialog shape..how to do that one .. plz help me if any body knows. now i am getting like this

Gunaseelan
  • 14,415
  • 11
  • 80
  • 128
Venkat
  • 3,447
  • 6
  • 42
  • 61
  • make 1 heart shape image and set as a background of your custom infowindow layout. – TheFlash May 23 '13 at 10:36
  • even i created the custom window but that window is display inside the default rectangle window @Pratik – Venkat May 23 '13 at 10:41
  • http://stackoverflow.com/questions/16317224/custom-infowindow-with-google-maps-api-v2/16318403#16318403 @Venkat – Shadow May 23 '13 at 10:44

1 Answers1

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>

this is your heart shape layout..copy and paste it in drable folder of your application...lolz Check This Download it

just inflate the above view into custom info window..!

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;

    }
});

this is just image i have created..you can add image better than me...if this works let me know...:)

Cœur
  • 37,241
  • 25
  • 195
  • 267
TheFlash
  • 5,997
  • 4
  • 41
  • 46
  • this does gives a custom layout however when I am adding multiple markers in a loop, setInfoWindowAdapter is only getting called once. I want to put some text in window but it shows the last text on all window – Vivek Mishra Mar 29 '18 at 18:53