Skip to main content
Version: 4.60

color

The color layer creates a colored area of the chosen color. It is most commonly used to create a background plane or to visually distinguish different elements from one another. The color layer can be used everywhere you can usually define layers.
To use the color layer it is important to set a value in form of a hex color code, i.e. #000000 for black or #ffffff for white, otherwise your color layer will be transparent.

Inherited

From Base Layer

Base Layer

Field Configurations

KeyTypeDescriptionDefault Value
"_value"Value[PREVIEW] Dynamic value of the layer.null
"accessibilityAppendState"StringDefines this layer appends its state to the accessibility text.null
"accessibilityText"StringText for accessibility navigation. Can be translated.null
"actions"ActionListList of actions, which will be executed when the layer is tapped.null
"borderColor"ColorThe color of the border in hex color value.null
"borderRadius"UnitSizeThe radius applies to all corners; with a borderWidth of 0 the border is not drawn and radius is set anyway.0
"borderWidth"UnitSizeThe width of the border.0
"bottomLeftRadius"UnitSizeRadius for the bottom left corner.0
"bottomRightRadius"UnitSizeRadius for the bottom right corner.0
"classes"ArrayList of classes for layer styles.null
"conditions"ConditionsList of conditions to alter the layer state.null
"constraints"ConstraintsA list of constraints defining the position of the layer in a layout.null
"consumesKeyboard"BooleanThis layer will be used to shrink, if a keyboard is shown.null
"dataKey"StringName for assigning data to this layer.null
"focusColor"ColorThe highlight color of this layer when it is focused. Mainly used on TV. If no color is provided, the pressedColor will be used.null
"hidden"BooleanIndicates whether the layer is hidden. Default: false.false
"isAccessibilityElement"StringDefines if this layer is important for accessibility navigation. The default depends on the layer type.null
"layerRotation"NumberThe layer is rotated by the specified degree.0
"name"StringUnique name in the layout. Used for alignment or actions.null
"opacity"NumberThe opacity of the layer.1
"overInsetBottom"BooleanDetermines if this layer ignores the save space at the bottom of the device.false
"overInsetTop"BooleanDetermines if this layer ignores the save space at the top of the device.false
"pressedColor"ColorThe highlight color of this layer when it is pressed. Mainly used on TV. If no color is provided, the focusColor will be used.null
"safeArea"SafeAreaTypeObjectDetermines the safe area behaviour.null
"shadowElevation"NumberThe elevation of this layer for casting shadows.0
"state"StringThe state the layer will use as default."default"
"states"LayerStatesA list of named states that affect the appearance of the layer.null
"topLeftRadius"UnitSizeRadius for the top left corner.0
"topRightRadius"UnitSizeRadius for the top right corner.0
"touchFeedback"TouchFeedbackDetermines if the layer should show a touch feedback if touched."visible"
"trackingKey"StringDefines a key for a scroll event.null
"type"LayerTypeThe type of the layernull
"value"Value(Initial) value of the layer.null

Examples

Example 1: Create a colored background

Goal: Create a background plane in the desired color spanning the whole screen.

To achieve this the following code can be used:

{
"type": "color",
"name": "backgroundColor",
"value": "#34a7c9",
"constraints": [
{
"type": "pos",
"x": "0pt",
"y": "0pt"
},
{
"type": "pos",
"x": "0pt",
"y": "0pt",
"anchor": "se",
"relativeAnchor": "se"
}
]
}

The value of the color layer is set to #1c8fc2 for a medium blue.
To have the color layer spanning the whole screen, the constraints are set accordingly from the top left to the bottom right corner of the display.

Result:

Screenshot of the app showing the results of the sample code from Example 1.
A color layer that covers the entire screen of the phone has been created.

Example 2: Create two elements that stand out visually from each other

Goal: Create two colored areas with different color values to easily distinguish them from the background and each other.

For this two additional layers of the type: color need to be defined, as seen in the following code:

{
"type": "color",
"name": "backgroundColor",
"value": "#34a7c9",
"constraints": [
{
"type": "pos",
"x": "0pt",
"y": "0pt"
},
{
"type": "pos",
"x": "0pt",
"y": "0pt",
"anchor": "se",
"relativeAnchor": "se"
}
]
}
{
"type": "color",
"name": "area1",
"value": "#f3f3f3",
"constraints": [
{
"type": "pos",
"x": "50pt",
"y": "50pt"
},
{
"type": "pos",
"x": "-50pt",
"y": "-300pt",
"anchor": "se",
"relativeAnchor": "se"
}
]
}
{
"type": "color",
"name": "area2",
"value": "#2b2f2f",
"constraints": [
{
"type": "pos",
"x": "70pt",
"y": "200pt"
},
{
"type": "pos",
"x": "-70pt",
"y": "-70pt",
"anchor": "se",
"relativeAnchor": "se"
}
]
}

The layer with the name: backgroundColor is the same as in the previous example. The other two layers named area1 and area2, are the elements that should stand out visually from each other. Therefore different values and constraints are set for each layer, which means that they differ in color, position and size.

Result:

Screenshot of the app showing the results of the sample code from Example 2.
Two additional color layers which visually stand out from each other have been created.