Switch (lv_switch)
Switch (lv_switch)
Overview
The Switch looks like a little slider and can be used to turn something on and off.
Parts and Styles
LV_PART_MAINThe background of the switch uses all the typical background style properties.paddingmakes the indicator smaller in the respective direction.LV_PART_INDICATORThe indicator that shows the current state of the switch. Also uses all the typical background style properties.LV_PART_KNOBA rectangle (or circle) drawn at left or right side of the indicator. Also uses all the typical background properties to describe the knob(s). By default the knob is square (with a optional corner radius) with side length equal to the smaller side of the slider. The knob can be made larger with thepaddingvalues. Padding values can be asymmetric too.
Usage
Change state
When the switch is turned on it goes to LV_STATE_CHECKED. To get the current satte of the switch use lv_obj_has_state(switch, LV_STATE_CHECKED). To manually turn the switch on/off call lvobj_add/clear_state(switch, LV_STATE_CHECKED).
Events
LV_EVENT_VALUE_CHANGEDSent when the switch changes state.
See the events of the Base object too.
Learn more about Events.
Keys
LV_KEY_UP/RIGHTTurns on the sliderLV_KEY_DOWN/LEFTTurns off the sliderLV_KEY_ENTERToggles the switch
Learn more about Keys.
Example
API
警告
doxygenfile: Unable to find project ‘lvgl’ in breathe_projects dictionary
浙公网安备 33010602011771号