diff --git a/demo/src/com/google/maps/android/utils/demo/IconGeneratorDemoActivity.java b/demo/src/com/google/maps/android/utils/demo/IconGeneratorDemoActivity.java index 472465aa7..58909108c 100644 --- a/demo/src/com/google/maps/android/utils/demo/IconGeneratorDemoActivity.java +++ b/demo/src/com/google/maps/android/utils/demo/IconGeneratorDemoActivity.java @@ -17,12 +17,19 @@ package com.google.maps.android.utils.demo; import android.graphics.Color; +import android.text.SpannableStringBuilder; +import android.text.style.StyleSpan; + import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.model.BitmapDescriptorFactory; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.MarkerOptions; import com.google.maps.android.ui.IconGenerator; +import static android.graphics.Typeface.BOLD; +import static android.graphics.Typeface.ITALIC; +import static android.text.Spannable.SPAN_EXCLUSIVE_EXCLUSIVE; + public class IconGeneratorDemoActivity extends BaseDemoActivity { @Override @@ -47,9 +54,14 @@ protected void startDemo() { iconFactory.setContentRotation(90); iconFactory.setStyle(IconGenerator.STYLE_GREEN); addIcon(iconFactory, "ContentRotate=90", new LatLng(-33.7677, 151.244)); + + iconFactory.setRotation(0); + iconFactory.setContentRotation(0); + iconFactory.setStyle(IconGenerator.STYLE_ORANGE); + addIcon(iconFactory, makeCharSequence(), new LatLng(-33.77720, 151.12412)); } - private void addIcon(IconGenerator iconFactory, String text, LatLng position) { + private void addIcon(IconGenerator iconFactory, CharSequence text, LatLng position) { MarkerOptions markerOptions = new MarkerOptions(). icon(BitmapDescriptorFactory.fromBitmap(iconFactory.makeIcon(text))). position(position). @@ -57,4 +69,14 @@ private void addIcon(IconGenerator iconFactory, String text, LatLng position) { getMap().addMarker(markerOptions); } + + private CharSequence makeCharSequence() { + String prefix = "Mixing "; + String suffix = "different fonts"; + String sequence = prefix + suffix; + SpannableStringBuilder ssb = new SpannableStringBuilder(sequence); + ssb.setSpan(new StyleSpan(ITALIC), 0, prefix.length(), SPAN_EXCLUSIVE_EXCLUSIVE); + ssb.setSpan(new StyleSpan(BOLD), prefix.length(), sequence.length(), SPAN_EXCLUSIVE_EXCLUSIVE); + return ssb; + } } diff --git a/library/src/com/google/maps/android/ui/IconGenerator.java b/library/src/com/google/maps/android/ui/IconGenerator.java index 13cd3361b..960c573a9 100644 --- a/library/src/com/google/maps/android/ui/IconGenerator.java +++ b/library/src/com/google/maps/android/ui/IconGenerator.java @@ -69,7 +69,7 @@ public IconGenerator(Context context) { * * @param text the text content to display inside the icon. */ - public Bitmap makeIcon(String text) { + public Bitmap makeIcon(CharSequence text) { if (mTextView != null) { mTextView.setText(text); }