Hello.
I am making like-whatsapp chat on ESP32+TFT display.
What I did? I have the varable msg_y (total heights of all elements) which equals 0 without messages. I create an object for message every time I receive or send message
lv_obj_t * incoming_message = lv_obj_create(ui_Screen1);
lv_obj_set_width(incoming_message, 200);
lv_obj_set_height(incoming_message, LV_SIZE_CONTENT);
lv_obj_set_x(incoming_message, 0);
lv_obj_set_y(incoming_message, msg_y);
lv_obj_t * incoming_message_text = lv_label_create(incoming_message);
lv_obj_set_width(incoming_message_text, lv_pct(100));
lv_obj_set_height(incoming_message_text, LV_SIZE_CONTENT); // the height equals text’s height
lv_label_set_text(incoming_message_text, “Hello!”);
msg_y = msg_y + lv_obj_get_height(incoming_message) + 20;
The last string increases msg_y with element’s height and 20 pixels more. So, if the first message has y coordinate 0 and message’s height is 80 px, the second message should start with 100 pixels (under 1st message) and it start on 20 pixels.
So, I found out that construction like
int32_t a = lv_obj_get_height(incoming_message);
returns zero.
And another question. How to scroll the main screen automatically yo the last element?