Important: unclear posts may not receive useful answers.
- Get familiar with Markdown to format and structure your post
- Be sure to update lvgl from the latest version from the
- Be sure you have checked the relevant part of the documentation.
- If applicable use the Simulator to eliminate hardware related issues.
Delete this section if you read and applied the mentioned points.
I have a black background behind the meter and I’m using transparent meter background. I’ve managed to set the major ticks color to white. However, the labels of the major ticks are still black - cannot be seen as the bg is also black. Is there a way to change their color to white as well?
What MCU/Processor/Board and compiler are you using?
What LVGL version are you using?
What do you want to achieve?
white meter major ticks labels
lv_meter_set_scale_major_ticks(meter1, scale, 3, 4, 20, lv_color_white(), 20);//create major tick
I’ve added two labels to represent the start and end values of the major ticks and set their text as variables - so they change whenever the scale range is changed. I think this will do for my application
lv_obj_t * meter_major_label_start = lv_label_create(meter);//create new label inside the meter
lv_label_set_recolor(meter_major_label_start, true);//enable recolor to set the color to white
lv_label_set_text_fmt(meter_major_label_start, "#ffffff %d", range_start);//set the color to while and use the start value of the range which is used in the scale
lv_obj_align(meter_major_label_start, meter, 20, 130);//Alight the label next to the starting major ick
//Do the same for the end of the range
lv_obj_t * meter_major_label_end = lv_label_create(meter);
lv_label_set_text_fmt(meter_major_label_end, "#ffffff %d", range_end);
lv_obj_align(meter_major_label_end, meter, 120, 130);
lv_obj_set_style_text_color(meter, lv_color_hex3(0xf80), LV_PART_TICKS);
This worked ! thanks a lot !
I believe this is better that just using labels and re-align them to the correct place as the rest of the major ticks between the first and last one will be without labels.
Glad to hear it worked.
Yes, it’s better to leave it to LVGL to calculate the position of these labels. Except if you need something really unorthodox