Skip To Content

Working with symbols and renderers

In this topic

Symbols define all non-geographic aspects of a graphic's appearance. This includes a graphic's color, border width, transparency, and more. The ArcGIS Runtime SDK for Android includes many symbol classes, each of which allows you to specify symbology in a unique way. Each symbol type is also specific to one geometry type (that is, point, line, or polygon).

Symbol types

The available symbols and associated geometries are summarized in the table below:

SymbolGeometryDescriptionSymbol class

Simple marker symbol

Point

Symbolizes points with simple shapes

SimpleMarkerSymbol

Picture marker symbol

Point

Symbolizes points with images

PictureMarkerSymbol

Simple line symbol

Polyline

Symbolizes lines with pre-defined styles

SimpleLineSymbol

Simple fill symbol

Polygon

Fills polygon with a variety of patterns

SimpleFillSymbol

Text symbol

Poine, polyline, or polygon

Displays text labels for geometries

TextSymbol

All of the symbol classes above inherit from the Symbol interface.

Renderers

A renderer defines a set of symbols used for graphics in a graphics layer. Use renderers to symbolize features with different colors or sizes based on the graphic's attribute values. To use a renderer, create it, define the symbology, then set the renderer property for the graphics layer. The following is a class diagram showing the renderer types you can create:

Renderer types

Create a simple renderer

A simple renderer uses the same symbol for every graphic. Create the renderer with the desired symbol, then the graphics layer’s renderer property.

// create a symbol for renderer
SimpleMarkerSymbol sms = new SimpleMarkerSymbol(Color.BLUE, 5, STYLE.CROSS);
// instantiate a simple renderer with the symbol created above
SimpleRenderer simRenderer = new SimpleRenderer(sms);
// add the renderer to the graphics layer
gLayer.setRenderer(simRenderer);

Create a class breaks renderer

A class breaks renderer symbolizes each graphic based on the value of a numeric attribute. Graphics with similar values for the attribute get the same symbol. The “breaks” define the values at which the symbology changes.

The following code creates a ClassBreaksRenderer to symbolize cities according to size. There are three class breaks: MIN_POP to 50,000, 50,000 to 250,000, and 250,000 to MAX_POP.

// instantiates a class break renderer
ClassBreaksRenderer cityPopRenderer = new ClassBreaksRenderer();
// set the attribute field used by renderer to match values 
cityPopRenderer.setField("POP1990");
// set the minimum population value = MIN_POP
cityPopRenderer.setMinValue(MIN_POP);
 
// create a class break representing the first
// low class break
ClassBreak lowClassBreak = new ClassBreak();
// set label as Low
lowClassBreak.setLabel("Low");
// set class break max value
lowClassBreak.setClassMaxValue(50000);
// set a pre-defined simple marker symbol
lowClassBreak.setSymbol(lowMarkerSymbol);
 
// create two more class breaks representing the
// mid and max class breaks
ClassBreak midClassBreak = new ClassBreak();
midClassBreak.setLabel("Middle");
midClassBreak.setClassMaxValue(250000);
midClassBreak.setSymbol(midMarkerSymbol);
ClassBreak highClassBreak = new ClassBreak();
highClassBreak.setLabel("High");
highClassBreak.setClassMaxValue(MAX_POP);
highClassBreak.setSymbol(maxMarkerSymbol);
 
// add class breaks to the class break renderer
cityPopRenderer.addClassBreak(lowClassBreak);
cityPopRenderer.addClassBreak(midClassBreak);
cityPopRenderer.addClassBreak(highClassBreak);
 
// add the class break renderer to the graphics layer
gLayer.setRenderer(cityPopRenderer);