Skip to main content

Switch

Overview

Switch toggle button

Example

<Switch android:layout_height="wrap_parent"
android:layout_width="match_parent"
android:tag="switch"
android:text="Button"
android:textColor="#669999"
android:textSize="14dp"
android:gravity="center"
android:checked="true"

/>

Properties

Common Properties

See Common Properties

Private Properties

PropertyDescriptionValues
layout_weightChild weightNumber
When the parent is LinearLayout, child controls can set weight
gravityInternal control alignmentUsage reference
top
bottom
left
right
center_vertical
fill_vertical
center_horizontal
fill_horizontal
center
fill
clip_vertical
clip_horizontal
checkedSelected statetrue: selected false: not selected
textTextString
textColorText colorHex, e.g. #FFFFFF
textSizeText sizespecific number + dp