Package com.google.maps.android.ui
Class IconGenerator
- java.lang.Object
-
- com.google.maps.android.ui.IconGenerator
-
public class IconGenerator extends java.lang.ObjectIconGenerator generates icons that contain text (or custom content) within an info window-like shape.The icon
Bitmaps generated by the factory should be used in conjunction with aBitmapDescriptorFactory.This class is not thread safe.
-
-
Field Summary
Fields Modifier and Type Field Description static intSTYLE_BLUEstatic intSTYLE_DEFAULTstatic intSTYLE_GREENstatic intSTYLE_ORANGEstatic intSTYLE_PURPLEstatic intSTYLE_REDstatic intSTYLE_WHITE
-
Constructor Summary
Constructors Constructor Description IconGenerator(android.content.Context context)Creates a new IconGenerator with the default style.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description floatgetAnchorU()floatgetAnchorV()android.graphics.BitmapmakeIcon()Creates an icon with the current content and style.android.graphics.BitmapmakeIcon(java.lang.CharSequence text)Sets the text content, then creates an icon with the current style.voidsetBackground(android.graphics.drawable.Drawable background)Set the background to a given Drawable, or remove the background.voidsetColor(int color)Sets the background to the default, with a given color tint.voidsetContentPadding(int left, int top, int right, int bottom)Sets the padding of the content view.voidsetContentRotation(int degrees)Rotates the contents of the icon.voidsetContentView(android.view.View contentView)Sets the child view for the icon.voidsetRotation(int degrees)Rotates the icon.voidsetStyle(int style)Sets the style of the icon.voidsetTextAppearance(int resid)Sets the text color, size, style, hint color, and highlight color from the specifiedTextAppearanceresource.voidsetTextAppearance(android.content.Context context, int resid)Sets the text color, size, style, hint color, and highlight color from the specifiedTextAppearanceresource.
-
-
-
Field Detail
-
STYLE_DEFAULT
public static final int STYLE_DEFAULT
- See Also:
- Constant Field Values
-
STYLE_WHITE
public static final int STYLE_WHITE
- See Also:
- Constant Field Values
-
STYLE_RED
public static final int STYLE_RED
- See Also:
- Constant Field Values
-
STYLE_BLUE
public static final int STYLE_BLUE
- See Also:
- Constant Field Values
-
STYLE_GREEN
public static final int STYLE_GREEN
- See Also:
- Constant Field Values
-
STYLE_PURPLE
public static final int STYLE_PURPLE
- See Also:
- Constant Field Values
-
STYLE_ORANGE
public static final int STYLE_ORANGE
- See Also:
- Constant Field Values
-
-
Method Detail
-
makeIcon
public android.graphics.Bitmap makeIcon(java.lang.CharSequence text)
Sets the text content, then creates an icon with the current style.- Parameters:
text- the text content to display inside the icon.
-
makeIcon
public android.graphics.Bitmap makeIcon()
Creates an icon with the current content and style.This method is useful if a custom view has previously been set, or if text content is not applicable.
-
setContentView
public void setContentView(android.view.View contentView)
Sets the child view for the icon.If the view contains a
TextViewwith the id "text", operations such assetTextAppearance(android.content.Context, int)andmakeIcon(CharSequence)will operate upon thatTextView.
-
setContentRotation
public void setContentRotation(int degrees)
Rotates the contents of the icon.- Parameters:
degrees- the amount the contents should be rotated, as a multiple of 90 degrees.
-
setRotation
public void setRotation(int degrees)
Rotates the icon.- Parameters:
degrees- the amount the icon should be rotated, as a multiple of 90 degrees.
-
getAnchorU
public float getAnchorU()
- Returns:
- u coordinate of the anchor, with rotation applied.
-
getAnchorV
public float getAnchorV()
- Returns:
- v coordinate of the anchor, with rotation applied.
-
setTextAppearance
public void setTextAppearance(android.content.Context context, int resid)Sets the text color, size, style, hint color, and highlight color from the specifiedTextAppearanceresource.- Parameters:
resid- the identifier of the resource.
-
setTextAppearance
public void setTextAppearance(int resid)
Sets the text color, size, style, hint color, and highlight color from the specifiedTextAppearanceresource.- Parameters:
resid- the identifier of the resource.
-
setStyle
public void setStyle(int style)
Sets the style of the icon. The style consists of a background and text appearance.
-
setColor
public void setColor(int color)
Sets the background to the default, with a given color tint.- Parameters:
color- the color for the background tint.
-
setBackground
public void setBackground(android.graphics.drawable.Drawable background)
Set the background to a given Drawable, or remove the background.- Parameters:
background- the Drawable to use as the background, or null to remove the background.
-
setContentPadding
public void setContentPadding(int left, int top, int right, int bottom)Sets the padding of the content view. The default padding of the content view (i.e. text view) is 5dp top/bottom and 10dp left/right.- Parameters:
left- the left padding in pixels.top- the top padding in pixels.right- the right padding in pixels.bottom- the bottom padding in pixels.
-
-