创建4个方向drop down list
/**
* Create a drop down, up, left and right menus
*/
static void lv_example_dropdown_2(void)
{
static const char* opts = "Apple\n"
"Banana\n"
"Orange\n"
"Melon"; //drop down选项文本内容
lv_obj_t* dd;
dd = lv_dropdown_create(lv_scr_act()); //创建drop down 对象
lv_dropdown_set_options_static(dd, opts); //设置选项列表内容
lv_obj_align(dd, LV_ALIGN_TOP_MID, 0, 10); //LV_ALIGN_TOP_MID方式对齐
dd = lv_dropdown_create(lv_scr_act()); //创建drop down 对象
lv_dropdown_set_options_static(dd, opts);//设置选项列表内容
lv_dropdown_set_dir(dd, LV_DIR_BOTTOM); //设置下拉列表方向为BOTTOM
lv_dropdown_set_symbol(dd, LV_SYMBOL_UP); // 设置drop down箭头符号为系统自带的LV_SYMBOL_UP
lv_obj_align(dd, LV_ALIGN_BOTTOM_MID, 0, -10);//LV_ALIGN_BOTTOM_MID方式对齐
dd = lv_dropdown_create(lv_scr_act()); //创建drop down 对象
lv_dropdown_set_options_static(dd, opts); //设置选项列表内容
lv_dropdown_set_dir(dd, LV_DIR_RIGHT); //设置下拉列表方向为LV_DIR_RIGHT
lv_dropdown_set_symbol(dd, LV_SYMBOL_RIGHT); // 设置drop down箭头符号为系统自带的LV_SYMBOL_RIGHT
lv_obj_align(dd, LV_ALIGN_LEFT_MID, 10, 0);//LV_ALIGN_LEFT_MID方式对齐
dd = lv_dropdown_create(lv_scr_act()); //创建drop down 对象
lv_dropdown_set_options_static(dd, opts);//设置选项列表内容
lv_dropdown_set_dir(dd, LV_DIR_LEFT); //设置下拉列表方向为LV_DIR_LEFT
lv_dropdown_set_symbol(dd, LV_SYMBOL_LEFT); // 设置drop down箭头符号为系统自带的LV_SYMBOL_LEFT
lv_obj_align(dd, LV_ALIGN_RIGHT_MID, -10, 0);//LV_ALIGN_RIGHT_MID方式对齐
}
运行效果