Using a custom font in Maps V2

I am trying to customize the presentation of the fragment and title in MapView using CommonsWare example
However, I cannot configure the Typeface fragment.
Custom Snippet MapsV2
Any luck?

+2
android android-textview android-maps-v2 infowindow
Mar 27 '13 at 20:09
source share
1 answer

If you extended the example from CommonsWare, you should have a PopupAdapter that is responsible for displaying your InfoWindow.

I expanded this PopupAdapter to download Typeface from my resources folder and set it as the type of the title and description fragment

class PopupAdapter implements InfoWindowAdapter { LayoutInflater inflater = null; // Context is most likely the map hosting activity. // We need this so we get access to the Asset Manager Context context = null; PopupAdapter(LayoutInflater inflater, Context context) { this.inflater = inflater; this.context = context; } @Override public View getInfoWindow(Marker marker) { return (null); } @Override public View getInfoContents(Marker marker) { View popup = inflater.inflate(R.layout.popup, null); TextView tv = (TextView) popup.findViewById(R.id.title); tv.setText(marker.getTitle()); // We load a typeface by using the static createFromAssets method // and provide the asset manager // and a path to the file within the assets folder Typeface tf = Typeface.createFromAsset(context.getAssets(), "GoodDog.otf"); // then set the TextViews typeface tv.setTypeface(tf); tv = (TextView) popup.findViewById(R.id.snippet); tv.setText(marker.getSnippet()); tv.setTypeface(tf); return (popup); } } 
+4
Mar 31 '13 at 14:13
source share



All Articles