Skip to content

Switch

Category Requires Version
User Interface API 21, Android 5.0 Lollipop 4

Overview

A visible component that lets the user toggle between two states — on and off.

Events

Clicked

Event invoked when a switch has been clicked. Returns true or false if the switch is checked or not.

whenSwitch.Clicked is Checked do
Params
is Checked Boolean

Methods

Thumb Image

Set the drawable used for the switch 'thumb' - the piece that the user can physically touch and drag along the track. If 'color Filter Enabled' is set to true, the image will get a light tint filter with the same color that you used as thumb color.

callSwitch.Thumb Imageimage
Params
image Text

Thumb Image From Material Font

Set the drawable used for the switch 'thumb' - the piece that the user can physically touch and drag along the track. You can find the icon name (or code) here at https://material.io/icons . Use as size as example '300'.

callSwitch.Thumb Image From Material Fonticon Namesize
Params
icon Name Text
size Number

Properties

Checked

Boolean Default: False ➖ Write - Designer Blocks

Set the toggle to checked or unchecked

setSwitch.Checked to 

Enabled

Boolean Default: True ➖ Read Write - Designer Blocks

If set to true, user can touch the switch.

Switch.Enabled
setSwitch.Enabled to 

Font Bold

Boolean Default: False ➖ Write - Designer

Property for FontBold

Font Italic

Boolean Default: False ➖ Write - Designer

Property for FontItalic

Font Size

Number Default: 14.0 ➖ Read Write - Designer Blocks

The text size of the switch.

Switch.Font Size
setSwitch.Font Size to 

Font Typeface

Number Default: 0 ➖ Write - Designer

Property for FontTypeface

Font Typeface Import

Available as Advanced Property

Text ➖ Write - Designer Blocks

Set a custom font.

setSwitch.Font Typeface Import to 

Height

Number ➖ Read Write - Blocks

Specifies the component's vertical height, measured in pixels.

Switch.Height
setSwitch.Height to 

Height Percent

Number ➖ Write - Blocks

Specifies the component's vertical height as a percentageof the height of its parent Component.

setSwitch.Height Percent to 

is Checked

Boolean ➖ Read - Blocks

Return true if the switch is checked else false.

Switch.is Checked

Text Color

Color Default: #4CAF50FF  ➖ Read Write - Designer Blocks

Set the text color for the switch.

Switch.Text Color
setSwitch.Text Color to 

Text Off

Text Default: Switch Off ➖ Read Write - Designer Blocks

Set here the switch off text. HTML tags are too possible: , ,

,
, , ,
, , , , , , , . Example: Test.

Switch.Text Off
setSwitch.Text Off to 

Text On

Text Default: Switch On ➖ Read Write - Designer Blocks

Set here the switch on text. HTML tags are too possible: , ,

,
, , ,
, , , , , , , . Example: Test.

Switch.Text On
setSwitch.Text On to 

Thumb Color

Color Default: #4CAF50FF  ➖ Read Write - Designer Blocks

Change the disabled color of the switch.

Switch.Thumb Color
setSwitch.Thumb Color to 

Track Color

Color Default: #009688FF  ➖ Read Write - Designer Blocks

Change the enabled color of the switch.

Switch.Track Color
setSwitch.Track Color to 

Visible

Boolean Default: True ➖ Read Write - Designer Blocks

Returns true iff the component is visible.

Switch.Visible
setSwitch.Visible to 

Width

Number ➖ Read Write - Blocks

Specifies the component's horizontal width, measured in pixels.

Switch.Width
setSwitch.Width to 

Width Percent

Number ➖ Write - Blocks

Specifies the component's horizontal width as a percentageof the Width of its parent Component.

setSwitch.Width Percent to