Description
Aligning a label with another label using any of the …OUT… enums does not appear to be working (for example LV_ALIGN_OUT_RIGHT_TOP). If I used any of the IN enums they do indeed work as expected. Am i doing something wrong?
What MCU/Processor/Board and compiler are you using?
Visual Studio simulation.
What do you want to achieve?
In my case alignment with the LV_ALIGN_OUT_RIGHT_TOP on its parent label, but none of the OUT enums appear to work. Label text is not shown!
What have you tried so far?
See below code
Code to reproduce
Here is a simplified version of my code which shows the problem
static void alignment_demo(lv_obj_t* parent)
{
lv_obj_t* container = lv_cont_create(parent, NULL);
lv_obj_align_origo(container, NULL, LV_ALIGN_CENTER, 0, 0);
lv_cont_set_layout(container, LV_LAYOUT_COL_M);
lv_cont_set_fit(container, LV_FIT_TIGHT);
static lv_style_t bigFont;
lv_style_copy(&bigFont, &lv_style_plain);
bigFont.text.font = &lv_font_roboto_28;
lv_obj_t* label1 = lv_label_create(container, NULL);
lv_label_set_text(label1, "Hello World");
lv_label_set_style(label1, LV_LABEL_STYLE_MAIN, &bigFont);
lv_obj_t* label2 = lv_label_create(container, NULL);
lv_label_set_text(label2, "==================================");
lv_obj_t* label3 = lv_label_create(label1, NULL);
lv_label_set_style(label3, LV_LABEL_STYLE_MAIN, &lv_style_plain);
lv_label_set_text(label3, "!!!!");
lv_obj_align(label3, NULL, LV_ALIGN_OUT_RIGHT_TOP, 0, 0);
//lv_obj_realign(label3);
}
Screenshot and/or video
This is what I am getting:
This is what I was expecting to see. I know I could achieve similar by having another container which is horizontally aligned but I want, in this example, the text “Hello World” to be centred and the smaller font text “!!!” to be aligned to the top right.
If I change the alignment to be INternal (LV_ALIGN_IN_TOP_RIGHT) then it does as I would expect: