Description
When using a button matrix, is it possible to have the buttons fit tightly around their contents?
The screenshot below shows a button matrix with “C:” and “M:” labels. These buttons expanded to fill the width of the parent container, and expanded in height to make the button a square. I would liket o make these buttons a similar size to the “x” and “^” buttons.
The button matrix has some styling applied to remove the margin and padding.
What MCU/Processor/Board and compiler are you using?
Windows x64, MSVC.
What LVGL version are you using?
7.9.1
What do you want to achieve?
Make the buttons in the button matrix fit tightly.
What have you tried so far?
I attempted to use lv_cont_set_fit(btn_drvmtrx, LV_FIT_TIGHT); but that’s not compatible with the button matrix object.
Code
Full code at https://github.com/deltabeard/haiyajan-lvgl/blob/master/src/main.c
What I currently use to create the button matrix:
lv_obj_t *btn_drvmtrx = lv_btnmatrix_create(cont, NULL);
lv_btnmatrix_set_map(btn_drvmtrx, btn_drvs_ptr);
lv_btnmatrix_set_one_check(btn_drvmtrx, true);
lv_btnmatrix_set_btn_ctrl_all(btn_drvmtrx, LV_BTNMATRIX_CTRL_CHECKABLE);
lv_obj_set_style_local_pad_all(btn_drvmtrx, LV_BTNMATRIX_PART_BG, LV_STATE_DEFAULT, 0);
lv_obj_set_style_local_margin_all(btn_drvmtrx, LV_BTNMATRIX_PART_BG, LV_STATE_DEFAULT, 0);
lv_obj_set_style_local_pad_all(btn_drvmtrx, LV_BTNMATRIX_PART_BTN, LV_STATE_DEFAULT, 0);
lv_obj_set_style_local_margin_all(btn_drvmtrx, LV_BTNMATRIX_PART_BTN, LV_STATE_DEFAULT, 0);
lv_obj_set_style_local_border_width(btn_drvmtrx, LV_BTNMATRIX_PART_BG, LV_STATE_DEFAULT, 0);
lv_obj_set_style_local_outline_width(btn_drvmtrx, LV_BTNMATRIX_PART_BG, LV_STATE_DEFAULT, 0);
Many thanks.