Class Callout.Style

  • Enclosing class:
    Callout

    public static final class Callout.Style
    extends Object
    Encapsulates a set of parameters that control how a callout looks. There are two alternative ways to construct a CalloutStyle object and set its contents:
    • Use the Style(Context) constructor and then call setter methods to set any parameters that require non-default values.
    • Use the Style(Context, int) constructor and provide an XML file in the res/xml folder of the application. The XML must contain a <calloutStyle> element with a number of optional attributes as described below.

    The parameters and their default values are shown below. This also gives the attribute names to use in the XML file if the latter option above is used.

    XML Attributes
    XML Attribute Description Default Value
    backgroundColor Background color of the callout. In XML this may be a color value or a reference to a color resource, for example "#FF0000" (RRGGBB) or "#FF808080" (AARRGGBB) or "@android:color/white". White
    borderColor Color of the border of the callout. In XML this may be a color value or a reference to a color resource, for example "#FF0000" or "@android:color/black". Black
    borderWidth Width of the border of the callout in density-independent pixels. 2
    cornerRadius Radius of curvature of the corners of the callout in density-independent pixels. 10
    maxHeight Maximum height of the callout in density-independent pixels. Full height of the MapView
    maxWidth Maximum width of the callout in density-independent pixels. Full width of the MapView
    minHeight Minimum height of the callout in density-independent pixels. Just sufficient to draw border and corners
    minWidth Minimum width of the callout in density-independent pixels. Just sufficient to draw border and corners
    leaderPosition Position style of the leader of the callout. See Callout.Style.LeaderPosition. LOWER_MIDDLE
    leaderLength Length of the leader of the callout in density-independent pixels. 12
    leaderWidth Width of the leader of the callout in density-independent pixels. 12

    Here's an example XML file:

      <?xml version="1.0" encoding="utf-8"?>
      <resources>
          <calloutStyle
              backgroundColor="#FFC0C0C0" // opaque gray
              borderColor="@android:color/white"
              borderWidth="4"
              cornerRadius="20"
              maxHeight="500"
              maxWidth="500"
              minHeight="100"
              minWidth="200"
              leaderPosition="AUTOMATIC"
              leaderLength="10"
              leaderWidth="20"
          />
      </resources>
     
    Since:
    100.0.0
    • Constructor Detail

      • Style

        public Style​(android.content.Context context)
        Constructor that sets all parameters to their default values. See Callout.Style for default values.
        Parameters:
        context - the current execution Context
        Since:
        100.0.0
      • Style

        public Style​(android.content.Context context,
                     int xmlResourceId)
        Constructor taking the resource ID for an XML document. Any parameters not included in the XML document will take default values as specified in Callout.Style.
        Parameters:
        context - the current execution Context
        xmlResourceId - the Android ID of an XML file in the res/xml folder of the application. The XML must contain a <calloutStyle> element, otherwise default values will be used for all parameters.
        Since:
        100.0.0
    • Method Detail

      • getBackgroundColor

        public int getBackgroundColor()
        Gets the background color. By default this is white (0xFFFFFFFF).
        Returns:
        the background color as 0xAARRGGBB
        Since:
        100.0.0
      • getBorderColor

        public int getBorderColor()
        Gets the border color. By default this is black (0xFF000000).
        Returns:
        the border color as 0xAARRGGBB
        Since:
        100.0.0
      • getBorderWidth

        public int getBorderWidth()
        Gets the border width.
        Returns:
        the border width in density-independent pixels
        Since:
        100.0.0
      • getCornerRadius

        public int getCornerRadius()
        Gets the corner curve radius.
        Returns:
        the corner curve radius in density-independent pixels
        Since:
        100.0.0
      • getMaxHeight

        public int getMaxHeight()
        Gets the maximum height of the callout.
        Returns:
        the maximum height of the callout window in density-independent pixels, or 0 if none has been set
        Since:
        100.0.0
      • getMaxWidth

        public int getMaxWidth()
        Gets the maximum width of the callout.
        Returns:
        the maximum width of the callout window in density-independent pixels, or 0 if none has been set
        Since:
        100.0.0
      • getMinHeight

        public int getMinHeight()
        Gets the minimum height of the callout. This is just sufficient to draw border and corners, unless a greater value has been set.
        Returns:
        the minimum height of the callout window in density-independent pixels
        Since:
        100.0.0
      • getMinWidth

        public int getMinWidth()
        Gets the minimum width of the callout. This is just sufficient to draw border and corners, unless a greater value has been set.
        Returns:
        the minimum width of the callout window in density-independent pixels
        Since:
        100.0.0
      • getLeaderLength

        public int getLeaderLength()
        Gets the leader length.
        Returns:
        the leader length in density-independent pixels
        Since:
        100.0.0
      • getLeaderPosition

        public Callout.Style.LeaderPosition getLeaderPosition()
        Gets the position of the leader relative to the body of the callout.
        Returns:
        the position of the leader
        Since:
        100.0.0
      • getLeaderWidth

        public int getLeaderWidth()
        Gets the leader width where it joins the body of the callout.
        Returns:
        the leader width in density-independent pixels
        Since:
        100.0.0
      • setBackgroundColor

        public void setBackgroundColor​(int backgroundColor)
        Sets the background color.
        Parameters:
        backgroundColor - the background color as 0xAARRGGBB
        Since:
        100.0.0
      • setBorderColor

        public void setBorderColor​(int borderColor)
        Sets the border color.
        Parameters:
        borderColor - the border color as 0xAARRGGBB
        Since:
        100.0.0
      • setBorderWidth

        public void setBorderWidth​(int borderWidth)
        Sets the border width. By default this is 2 density-independent pixels.
        Parameters:
        borderWidth - the border width in density-independent pixels
        Since:
        100.0.0
      • setCornerRadius

        public void setCornerRadius​(int cornerRadius)
        Sets the corner curve radius. By default this is 10 density-independent pixels.
        Parameters:
        cornerRadius - the corner curve radius in density-independent pixels
        Since:
        100.0.0
      • setMaxHeight

        public void setMaxHeight​(int maxHeight)
        Sets the maximum height of the callout. By default it will stretch to accommodate the content that is to appear inside it, limited only by the height of the MapView.
        Parameters:
        maxHeight - the maximum height of the callout in density-independent pixels
        Since:
        100.0.0
      • setMaxWidth

        public void setMaxWidth​(int maxWidth)
        Sets the maximum width of the callout. By default it will stretch to accommodate the content that is to appear inside it, limited only by the width of the MapView.
        Parameters:
        maxWidth - the maximum width of the callout in density-independent pixels
        Since:
        100.0.0
      • setMinHeight

        public void setMinHeight​(int minHeight)
        Sets the minimum height of the callout. By default it will be just sufficient to draw border and corners.
        Parameters:
        minHeight - the minimum height of the callout in density-independent pixels
        Since:
        100.0.0
      • setMinWidth

        public void setMinWidth​(int minWidth)
        Sets the minimum width of the callout. By default it will be just sufficient to draw border and corners.
        Parameters:
        minWidth - the minimum width of the callout in density-independent pixels
        Since:
        100.0.0
      • setLeaderLength

        public void setLeaderLength​(int leaderLength)
        Sets the leader length. By default this is 12 density-independent pixels.
        Parameters:
        leaderLength - the leader length in density-independent pixels
        Since:
        100.0.0
      • setLeaderWidth

        public void setLeaderWidth​(int leaderWidth)
        Sets the leader width where it joins the body of the callout. By default this is 12 density-independent pixels.
        Parameters:
        leaderWidth - the leader width in density-independent pixels
        Since:
        100.0.0