2

我正在开发一个使用 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 背景?如果是这样,怎么做?

4

2 回答 2

2

您可以添加自定义 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");
于 2017-05-30T22:02:40.453 回答
-1

您创建了 Background Elementary Widget ,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;
}
于 2016-11-28T10:50:29.313 回答