I did with the simplest way as shown below:
private GoogleMap mMap;
While adding a marker to Google Map :
LatLng mLatLng = new LatLng(YourLatitude, YourLongitude); mMap.addMarker(new MarkerOptions().position(mLatLng).title("My Title").snippet("My Snippet"+"\n"+"1st Line Text"+"\n"+"2nd Line Text"+"\n"+"3rd Line Text").icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)));
After that, enter the InfoWindow adapter in the Google Map :
mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() { @Override public View getInfoWindow(Marker arg0) { return null; } @Override public View getInfoContents(Marker marker) { LinearLayout info = new LinearLayout(mContext); info.setOrientation(LinearLayout.VERTICAL); TextView title = new TextView(mContext); title.setTextColor(Color.BLACK); title.setGravity(Gravity.CENTER); title.setTypeface(null, Typeface.BOLD); title.setText(marker.getTitle()); TextView snippet = new TextView(mContext); snippet.setTextColor(Color.GRAY); snippet.setText(marker.getSnippet()); info.addView(title); info.addView(snippet); return info; } });
Hope this helps you.
Hiren Patel Jul 25 '15 at 17:38 2015-07-25 17:38
source share