How to change the custom form of InfoWidnow maps google api v2

I have now displayed the default shape of the rectangle 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() + " 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 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 of a heart shape, means a custom shape, like the shape of a chart diagram. How to do this ... plz help me if any body knows. now i am getting like this

+3
android google-maps
source share
1 answer

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 into the draping folder of your application ... lolz Check this Download

just inflate the above view in the 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 an image that I created. You can add an image better than me ... if it works let me know ... :)

+14
source share

All Articles