How to move a button's label?

my code is shown below:

test_create(lv_obj_t* parent)
{
lv_obj_t* btn = lv_btn_create(parent, NULL);

lv_obj_t* label = lv_label_create(btn, NULL);
lv_label_set_text(label, “TEST”);

lv_obj_set_pos(label, 0, 100);

}

the code “lv_obj_set_pos(label, 0, 100)” doesn’t work? why? label is the child of btn, the funtion “lv_obj_set_pos” should be work ok, but it doesn’t work? i can not move the label’s position.

hi,
You should read the documentation.
“So if you add a label, then it will be automatically aligned to the middle and can’t be moved with lv_obj_set_pos().”
If you want to move a label, you should create keep separate from the button.

2 Likes

Thanks a lot.