我正在开发一个使用GenList显示信息的Galaxy Gear S2应用程序。该应用程序的要求之一是Genlist应该具有橙色背景而不是黑色背景。我一直在使用此网站作为指导。
我已经更改了窗口的背景,但是窗户背景似乎是Genlist背后的背后。这意味着仅在窗口之间更改时,背景颜色仅显示。
GenList看起来如下。
static void create_first_list(appdata_s *ad){
Evas_Object *genlist = NULL;
Evas_Object *naviframe = ad ->naviframe;
Elm_Object_Item *nf_it = NULL;
Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
Elm_Genlist_Item_Class *titc = elm_genlist_item_class_new();
Elm_Genlist_Item_Class *pitc = elm_genlist_item_class_new();
item_data *id = NULL;
int index = 0;
local_ad = ad;
genlist = elm_genlist_add(naviframe);
elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
evas_object_smart_callback_add(genlist, "selected", NULL, NULL);
ad->circle_genlist = eext_circle_object_genlist_add(genlist, ad->circle_surface);
eext_circle_object_genlist_scroller_policy_set(ad->circle_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
eext_rotary_object_event_activated_set(ad->circle_genlist, EINA_TRUE);
itc->item_style = "1text";
itc->func.text_get = _gl_main_text_getfirst;
itc->func.del = _gl_menu_del;
titc->item_style = "title";
titc->func.text_get = _gl_title_text_get;
titc->func.del = _gl_menu_del;
pitc->item_style = "padding";
elm_genlist_item_append(genlist, titc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, ad);
id = calloc(sizeof(item_data), 1);
id->index = index++;
id->item = elm_genlist_item_append(genlist, itc, id, NULL, ELM_GENLIST_ITEM_NONE, btn_cb_connect, ad);
elm_genlist_item_append(genlist, pitc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, ad);
elm_genlist_item_class_free(titc);
elm_genlist_item_class_free(itc);
elm_genlist_item_class_free(pitc);
local_ad->naviframe = naviframe;
nf_it = elm_naviframe_item_push(naviframe, NULL, NULL, NULL, genlist, "empty");
elm_naviframe_item_pop_cb_set(nf_it, _naviframe_pop_cb, ad->win);
}
此Genlist仅包含一个项目。我已经通过在GenList生成方法中执行以下操作来改变背景颜色。
elm_bg_color_set(Genlist,255,168,0);
这不起作用,可以改变Genlist的背景。有没有办法改变整个Genlist背景?如果是这样,如何?
您可以添加自定义GenList样式:
collections {
images {
image: "bg.png" COMP;
}
group {
name: "elm/genlist/base/custom";
parts {
part { // Here you can set solid bg color
name: "bg";
type: RECT;
description {
color: 231 232 142 255;
}
}
part { // And any image as bg here
name: "bg_image";
type: IMAGE;
description {
image.normal: "bg.png";
}
}
part {
name: "pd.top";
type: SPACER;
description {
min: 0 30;
max: -1 30;
fixed: 0 1;
align: 0.5 0.0;
}
}
part {
name: "elm.swallow.content";
type: SWALLOW;
description {
rel1 {
relative: 0.0 1.0;
to_y: "pd.top";
}
}
}
}
}
以样式扩展默认主题:
elm_theme_extension_add(NULL, "path_to_file_containing_custom_style.edj");
并适用于GenList:
elm_object_style_set(genlist, "custom");
使用elm_bg_add()
创建背景基本小部件,但您没有可见。
,如果您使用elm_win_util_standard_add()
创建了窗口。默认背景是在窗口中创建的。
因此,请单独使用elm_win_add()
和elm_bg_add()
。
以下代码是elm_win_util_standard_add()
的实现。只需喜欢此代码并更改bg
的颜色。
EAPI Evas_Object *
elm_win_util_standard_add(const char *name, const char *title)
{
Evas_Object *win, *bg;
win = elm_win_add(NULL, name, ELM_WIN_BASIC);
if (!win) return NULL;
elm_win_title_set(win, title);
bg = elm_bg_add(win);
if (!bg)
{
evas_object_del(win);
return NULL;
}
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bg);
evas_object_show(bg);
return win;
}