我正在开发一个使用genlist来显示信息的Galaxy Gear S2应用程序。该应用程序的要求之一是genlist应该具有橙色背景而不是黑色背景。我一直在使用this site作为指导。
我已经改变了窗口的背景,但是windows背景似乎落后于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背景?如果是这样,怎么样?
答案 0 :(得分:1)
您可以添加自定义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");
答案 1 :(得分:-1)
您使用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;
}