How to change the roller selected text font size

Important: posts that do not use this template will be ignored or closed.

Before posting

  • Get familiar with Markdown to format and structure your post
  • Be sure to update lvgl from the latest version from the master branch.
  • Be sure you have checked the relevant part of the documentation. We will not respond in detail to posts where you haven’t read the relevant documentation.
  • If applicable use the Simulator to eliminate hardware related issues.

Delete this section if you read and applied the mentioned points.


What MCU/Processor/Board and compiler are you using?

visual studio PC monitor

What do you want to achieve?

Change the roller widget selected font size.

What have you tried so far?

I set the roller’s bg_style and sel_style and fond the seleced fond didn’t work

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

/*You code here*/
    /*roller backgroud style set*/
	static lv_style_t  rollerbg_style;
	rollerbg_style.body.main_color = LV_COLOR_BLACK;
	rollerbg_style.body.grad_color = LV_COLOR_BLACK;
	rollerbg_style.body.opa = LV_OPA_100;
	rollerbg_style.body.radius = 12;
	rollerbg_style.text.font = &Alibaba_PuHuiTi_M_Alarm30px;
	rollerbg_style.text.opa = LV_OPA_100;
	rollerbg_style.text.line_space = 42;
	rollerbg_style.text.color = LV_COLOR_GRAY;

	/*roller seltext style set */
	static lv_style_t rollersel_style;
	lv_style_copy(&rollersel_style, &lv_style_transp);
	rollersel_style.body.main_color = LV_COLOR_BLACK;
	rollersel_style.body.grad_color = LV_COLOR_BLACK;
	rollersel_style.body.radius= 1;
	rollersel_style.body.opa = LV_OPA_0;/*completely opa*/
	rollersel_style.text.font = &Alibaba_PuHuiTi_M_Alarm45px;
	rollersel_style.line.width = 10;
	rollersel_style.text.opa = LV_OPA_100;
	rollersel_style.text.line_space = 61;
	rollersel_style.text.color = LV_COLOR_MAKE(0x00, 0xd8, 0xff);

	const char *HourBuf = "00\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23";
	lv_obj_t * hour_roller = lv_roller_create(tabalarm1, NULL);
	lv_roller_set_style(hour_roller, LV_ROLLER_STYLE_BG,&rollerbg_style);
	lv_roller_set_style(hour_roller, LV_ROLLER_STYLE_SEL, &rollersel_style);
	lv_roller_set_options(hour_roller, HourBuf, LV_ROLLER_MODE_INIFINITE);
	lv_roller_set_visible_row_count(hour_roller, 3);
	lv_obj_set_event_cb(hour_roller, hue_select_event_cb);

	const char *MinuteBuf = "00\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30"
	lv_obj_t * minute_roller = lv_roller_create(tabalarm1, NULL);
	lv_roller_set_style(minute_roller, LV_ROLLER_STYLE_BG, &rollerbg_style);
	lv_roller_set_style(minute_roller, LV_ROLLER_STYLE_SEL, &rollersel_style);
	lv_roller_set_options(minute_roller, MinuteBuf, LV_ROLLER_MODE_INIFINITE);
	lv_roller_set_visible_row_count(minute_roller, 3);
	lv_obj_set_event_cb(minute_roller, hue_select_event_cb);
	lv_obj_set_pos(minute_roller, 197, 68);

## Screenshot and/or video
If possible, add screenshots and/or videos about the current state.

##I want like following:

It’s a limitation in the current version. The selected font needs to be the same as the background font.

I’m very thank you gei me answer and I’m very sorry for too late respond,for too much overtime rencently.
I have set too font style for roller,one for rollerbgstyle the other for rollerselstyle,but the selected and unselect text’s font size just as the rollerbgstyle .No matter how i change the two style they are only one style.
Does the DEV7.0 support change select font size?

No. It’s stil not supported in v7.

Would you consider supporting this feature in subsequent versions?

It’s already added. You can set a larger font for LV_ROLLER_PART_SELECTED.

When I tried it I’ve noticed a small bug and fixed it. So be sure to use the latest master version.

Thank you very much ,I will try it. :smiley:I am very admire your serious attitude

1 Like