Description
Hey guys,
I’d like to create a simple horizontal line which divides the parent into 2 equal parts. For this one I have chosen lv_line but i’m failing to get the line to the correct position
What MCU/Processor/Board and compiler are you using?
=>Windows PC Simulator
What LVGL version are you using?
=>9.1
What do you want to achieve?
See above, trying to create a horizontal line
What have you tried so far?
see code below
Code to reproduce
The code block(s) should be formatted like:
///basic horizontal line points (split parent into 2 equal parts)
static constexpr std::array horizontalLinePoints = {
lv_point_precise_t {LV_PCT(0), LV_PCT(50)},
lv_point_precise_t {LV_PCT(100), LV_PCT(50)} };
static lv_obj_t* pLine = nullptr;
void createLine(lv_obj_t* pParent)
{
//parent object size has already been set to
//lv_obj_set_size(pParent, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
pLine = lv_line_create(pParent);
//as stated in the doc we need to set the width and height explicitly when using lv_pct()
lv_obj_update_layout(pParent);
const auto parentWidth = lv_obj_get_width(pParent);
lv_obj_set_width(pLine , parentWidth );
lv_obj_set_height(pLine, 10);
lv_line_set_points(getLvObj(), horizontalLinePoints.data(), static_cast<uint32_t>(horizontalLinePoints.size()));
}
Screenshot and/or video
Now as you can see this line is not in the center. How can I move this line to the center of the blue box?
thx for your help guys