hi, i have some questions in my project.
i follow the “demo” project, then i have some questions shown below:
1.Can I set the size of button in the tabview? Like in the top of the picture I uploaded, how to
set size of the button in the tabview? Because I want set the buttons on the left, but after I used the function lv_obj_set_size(), I found the button is too small, so I want to enlarge it.
2. How to change the color of the bar I circled in the picture?
my code is shown below:
/*\brief Create a tabview
* 创建左侧垂直标签
*/
static void create_tabview(lv_obj_t* parent, lv_coord_t hres, lv_coord_t vres)
{
/* 设置tabview的button背景样式 */
static lv_style_t style_tv_btn_bg;
lv_style_copy(&style_tv_btn_bg, &lv_style_plain_color);
style_tv_btn_bg.body.main_color = LV_COLOR_BLACK;
style_tv_btn_bg.body.grad_color = LV_COLOR_BLACK;
style_tv_btn_bg.body.opa = LV_OPA_30;
style_tv_btn_bg.body.radius = 0;
style_tv_btn_bg.body.padding.top = 0;
style_tv_btn_bg.body.padding.bottom = 0;
style_tv_btn_bg.body.padding.left = 0;
style_tv_btn_bg.body.padding.right = 0;
/* 设置tabview的button释放样式 */
static lv_style_t style_tv_btn_rel;
lv_style_copy(&style_tv_btn_rel, &lv_style_plain_color);
style_tv_btn_rel.body.main_color = lv_color_hex(0x41A920);
style_tv_btn_rel.body.grad_color = lv_color_hex(0x41A920);
style_tv_btn_rel.body.opa = LV_OPA_COVER;
style_tv_btn_rel.body.radius = 0;
style_tv_btn_rel.body.border.width = 0;
style_tv_btn_rel.text.color = LV_COLOR_WHITE;
/* 设置tabview的button按下样式 */
static lv_style_t style_tv_btn_pr;
lv_style_copy(&style_tv_btn_pr, &lv_style_plain_color);
style_tv_btn_pr.body.radius = 0;
style_tv_btn_pr.body.opa = LV_OPA_50;
style_tv_btn_pr.body.main_color = LV_COLOR_WHITE;
style_tv_btn_pr.body.grad_color = LV_COLOR_WHITE;
style_tv_btn_pr.body.border.width = 0;
style_tv_btn_pr.text.color = LV_COLOR_WHITE;
/* 创建tabview */
lv_obj_t * tv = lv_tabview_create(lv_disp_get_scr_act(NULL), NULL);
//lv_tabview_set_btns_pos(tv, LV_TABVIEW_BTNS_POS_LEFT);
lv_obj_set_size(tv, hres, vres);
lv_obj_set_parent(parent, ((lv_tabview_ext_t *) tv->ext_attr)->content);
lv_obj_set_pos(parent, 0, -30);
/* 分别创建标签页 */
lv_obj_t * tab1 = lv_tabview_add_tab(tv, "主接线图");
lv_obj_t * tab2 = lv_tabview_add_tab(tv, "事件记录");
lv_obj_t * tab3 = lv_tabview_add_tab(tv, "装置状态");
lv_obj_t * tab4 = lv_tabview_add_tab(tv, "参数设置");
lv_tabview_set_style(tv, LV_TABVIEW_STYLE_BTN_BG, &style_tv_btn_bg);
lv_tabview_set_style(tv, LV_TABVIEW_STYLE_INDIC, &lv_style_plain);
lv_tabview_set_style(tv, LV_TABVIEW_STYLE_BTN_REL, &style_tv_btn_rel);
lv_tabview_set_style(tv, LV_TABVIEW_STYLE_BTN_PR, &style_tv_btn_pr);
lv_tabview_set_style(tv, LV_TABVIEW_STYLE_BTN_TGL_REL, &style_tv_btn_rel);
lv_tabview_set_style(tv, LV_TABVIEW_STYLE_BTN_TGL_PR, &style_tv_btn_pr);
write_create(tab1);
list_create(tab2);
chart_create(tab3);
test_create(tab4);
}
/*\brief Create a display
* 创建一个GUI显示
*/
void display_create(void)
{
lv_coord_t hres = lv_disp_get_hor_res(NULL);
lv_coord_t vres = lv_disp_get_ver_res(NULL);
lv_obj_t* wallpaper = create_wallpaper(hres, vres);
create_tabview(wallpaper, hres, vres);
}