diff --git a/docs/details/widgets/label.rst b/docs/details/widgets/label.rst index 4b49f9451..35137ed05 100644 --- a/docs/details/widgets/label.rst +++ b/docs/details/widgets/label.rst @@ -117,6 +117,18 @@ this implementation detail is unnoticed. This is not the case with :cpp:func:`lv_label_set_text_static` must be writable if you plan to use :cpp:enumerator:`LV_LABEL_LONG_DOT`. +.. _lv_label_text_recolor: + +Text recolor +------------ + +In the text, you can use commands to recolor parts of the text. +For example: ``Write a #ff0000 red# word``. This feature can be enabled +individually for each label by :cpp:expr:`lv_label_set_recolor(label, en)` +function. In the context of word-wrapped text, any Recoloring started on a +line will be terminated at the end of the line where the line is wrapped if it +was not already terminated by an ending ``#`` in the text. + .. _lv_label_text_selection: Text selection diff --git a/examples/widgets/label/lv_example_label_1.c b/examples/widgets/label/lv_example_label_1.c index 200444e02..e350bfad4 100644 --- a/examples/widgets/label/lv_example_label_1.c +++ b/examples/widgets/label/lv_example_label_1.c @@ -8,7 +8,9 @@ void lv_example_label_1(void) { lv_obj_t * label1 = lv_label_create(lv_screen_active()); lv_label_set_long_mode(label1, LV_LABEL_LONG_MODE_WRAP); /*Break the long lines*/ - lv_label_set_text(label1, "Recolor is not supported for v9 now."); + lv_label_set_recolor(label1, true); /*Enable re-coloring by commands in the text*/ + lv_label_set_text(label1, "#0000ff Re-color# #ff00ff words# #ff0000 of a# label, align the lines to the center " + "and wrap long text automatically."); lv_obj_set_width(label1, 150); /*Set smaller width to make the lines wrap*/ lv_obj_set_style_text_align(label1, LV_TEXT_ALIGN_CENTER, 0); lv_obj_align(label1, LV_ALIGN_CENTER, 0, -40);