How to change the height of btn in btnmatrix?


How to change the height of btn in button matrix?

What MCU/Processor/Board and compiler are you using?

What LVGL version are you using?


What do you want to achieve?

change one of button’s height in button matrix.

What have you tried so far?

search in forum

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

static const char * btnm_map[] = {"7","8", "9", "\n",
                                    "4", "5", "6", "\n",
                                    "1", "2", "3",  "\n",
                                    "0", ".", ""};

btn_matrix_num = lv_btnmatrix_create(m_lvObj);
lv_btnmatrix_set_map(btn_matrix_num, btnm_map);
lv_obj_set_pos(btn_matrix_num, 30, 80);
lv_obj_set_size(btn_matrix_num, 300, 300);
lv_obj_set_style_radius(btn_matrix_num, 0, LV_PART_ITEMS);
lv_obj_set_style_pad_gap(btn_matrix_num, 4, 0);

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

I am also wondering how to do this. Is there any sugestion for this?

still no solution for this?

ok so when lv_btnmatrix_set_map is called one of the things it does is sets the “area” of the buttons. This area is what defines the width and height of the buttons. The height is calculated based on what the total height of the widget is. So if you want to increase the height of the buttons you would need to increase the height of the widget itself.

That being said. If for whatever reason you did not want to increase the height of the widget and you wanted to increase the height of the buttons. you can access the button areas in lv_btnmatrix_t. they are located in the button_areas field which is an array of lv_area_t. lv_area_t has 4 fields and those fields define what the upper left corner is and the lower right corner is. x1, y1, x2, y2 are the fields. Changing either y1 or y2 is going to change the height of the button. Keep in mind this array is not only for the purpose of the button size it is also for the button position. So it is possible to say shift every other column up by 1/2 a button width. This would give you a different kind of effect with the matrix.