How to change the colour of a spinner indicator

Hello, I’m using LVGL v8

I want to change the colour of this part of the spinner
image

I tried to set the obj bg colour and opc bg color to green but it won’t work

    lv_color_t Green = lv_color_hsv_to_rgb(148, 92, 62);//Background color
    spinner = lv_spinner_create(parent, 1000, 60);
    lv_obj_set_size(spinner, 100, 100);
    lv_obj_set_style_bg_color(spinner, Green, LV_PART_INDICATOR);
    lv_obj_set_style_bg_opa(spinner, LV_OPA_100, LV_PART_INDICATOR);

I tried to add it as a style:

    lv_color_t Green = lv_color_hsv_to_rgb(148, 92, 62);//Background color
    static lv_style_t spinnerStyle_1;
    lv_style_init(&spinnerStyle_1);
    lv_style_set_line_color(&spinnerStyle_1, Green);
    lv_style_set_line_width(&spinnerStyle_1, 2);
    lv_style_set_bg_opa(&spinnerStyle_1, LV_OPA_COVER);
    lv_style_set_bg_color(&spinnerStyle_1, Green);
    lv_obj_add_style(spinner, &spinnerStyle_1, LV_PART_INDICATOR);

But still it won’t change for some reason = \

I used SquareLine Studio to generate this:

// SquareLine LVGL GENERATED FILE
// EDITOR VERSION: SquareLine Studio 1.0.3
// LVGL VERSION: 8.2
// PROJECT: NewProject

#include "ui.h"
#include "ui_helpers.h"

///////////////////// VARIABLES ////////////////////
lv_obj_t * ui_Screen1;
lv_obj_t * ui_Spinner1;

///////////////////// ANIMATIONS ////////////////////

///////////////////// FUNCTIONS ////////////////////

///////////////////// SCREENS ////////////////////
void ui_Screen1_screen_init(void)
{

    // Screen1

    ui_Screen1 = lv_obj_create(NULL);

    lv_obj_clear_flag(ui_Screen1, LV_OBJ_FLAG_SCROLLABLE);

    // Spinner1

    ui_Spinner1 = lv_spinner_create(ui_Screen1, 1000, 90);

    lv_obj_set_width(ui_Spinner1, 80);
    lv_obj_set_height(ui_Spinner1, 80);

    lv_obj_set_x(ui_Spinner1, 0);
    lv_obj_set_y(ui_Spinner1, 0);

    lv_obj_set_align(ui_Spinner1, LV_ALIGN_CENTER);

    lv_obj_clear_flag(ui_Spinner1, LV_OBJ_FLAG_CLICKABLE);

    lv_obj_set_style_arc_color(ui_Spinner1, lv_color_hex(0xFF0000), LV_PART_INDICATOR | LV_STATE_DEFAULT);
    lv_obj_set_style_arc_opa(ui_Spinner1, 255, LV_PART_INDICATOR | LV_STATE_DEFAULT);

}

void ui_init(void)
{
    ui_Screen1_screen_init();
    lv_disp_load_scr(ui_Screen1);
}

I hope it helps :slight_smile:

Perfect!

Thanks a lot

image

1 Like