Evan
January 13, 2020, 7:45am
1
Hi:
i want to show a text in the center of the lcd, but the text was be displayed at the first line of the lcd,
Please help me to check my codes, thanks!
LV_HOR_RES 320
LV_VER_RES 240
/Create a page /
if(info_page == NULL)
{
info_page = lv_page_create(lv_scr_act(), NULL);
lv_obj_set_size(info_page, LV_HOR_RES, LV_VER_RES);
lv_obj_align(info_page, NULL, LV_ALIGN_CENTER, 0, 0);
lv_page_set_style(info_page, LV_PAGE_STYLE_BG, &menu_bg_style);
lv_page_set_style(info_page, LV_PAGE_STYLE_SCRL, &menu_bg_style);
lv_page_set_style(info_page, LV_PAGE_STYLE_SB, &menu_bg_style);
lv_page_set_sb_mode(info_page, LV_SB_MODE_AUTO);
}
lv_obj_t *label;
/*second line fxo info*/
label = lv_label_create(info_page, NULL);
lv_label_set_style(label, &menu_sel_style);
lv_label_set_text(label, infoString);
lv_obj_align(label, info_page,LV_ALIGN_IN_TOP_MID, 0,124);
Anda
January 13, 2020, 8:07am
2
Hi, you can modify like this
Evan:
lv_obj_align(label, info_page,LV_ALIGN_IN_TOP_MID, 0,124);
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
Evan
January 13, 2020, 8:16am
3
I modify the code like this lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0); the problem also exist,
Anda
January 13, 2020, 8:17am
4
You can show some pictures about this.
Anda
January 13, 2020, 8:29am
5
Here you have to modify like this
lv_label_set_style(label, LV_LABEL_STYLE_MAIN, &menu_sel_style);
or
lv_obj_set_style(lable, &menu_sel_style);
Evan
January 13, 2020, 8:46am
6
Anda:
lv_label_set_style
my littevGL verison is 5.0, now the text dispotion is right, but some times the text will displayed at the (0,0),please see the video
Evan
January 13, 2020, 8:52am
7
You can see the picture, my demo have a countdown , the lcd will display the time in the center, but, sometime the text will display at the (0,0) like the “7s”
Anda
January 13, 2020, 8:55am
8
Hmm, can you show more code about the text update process?
Evan
January 13, 2020, 8:58am
9
Sorry, the code is too large, can you give me some advice to find the proplem?
Anda
January 13, 2020, 8:59am
10
Okay, that’s all right.
The important point is that the lv_style_t variable should be static or global variable, you can check it.
5.0 is very, very old… we don’t really support it anymore. Is there a reason why you can’t upgrade to 6.0, at the very least?