How to change the background colour on Text area

I’ve created a Text area and managed to put text on it.

I now want to change the background colour. In the documentation
It mentioned Style usage:

lv_ta_set_style(page, LV_TA_STYLE_…, &style)

but I’m bit lost on the page parameter.

I’ve tried
static lv_style_t style_ta;
lv_style_copy(&style_ta, &lv_style_plain);
lv_ta_set_style(page,LV_TA_STYLE_BG,&style_ta) = LV_COLOR_ORANGE;

but not sure about the page parameter. Do I need to create a page ?

What is the correct way to set the background colour for Text area ?

static lv_style_t style_ta;
lv_style_copy(&style_ta, lv_ta_get_style(ta, LV_TA_STYLE_BG));
style_ta.body.main_color = style_ta.body.grad_color = <your color>;

Wow, that works.

Thank you very much.

1 Like