Adding Background Image to Box

Adding Background Image to Box

BY 02 Mar 2015 Native Application Development

Hi All,

I am trying to add background image to a Box container.

But with all option set using below code I am not able to see any background image after installing App.

    Evas_Object *image_box = elm_box_add(mbox);
    elm_box_horizontal_set(image_box, EINA_FALSE);
    elm_box_padding_set(image_box, 16, 10);
    evas_object_size_hint_weight_set(image_box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(image_box, EVAS_HINT_FILL, EVAS_HINT_FILL);

    Evas_Object *img_bg = elm_bg_add(image_box);
    char bg_path[200] = {0};
    sprintf(bg_path, “%s%s”, app_get_resource_path(), “img/headerbg_portrait.png”);
    elm_bg_file_set(img_bg, bg_path, NULL);
    elm_bg_color_set(img_bg, 0,40, 40);
    elm_bg_option_set(img_bg, ELM_BG_OPTION_SCALE);
    evas_object_size_hint_weight_set(img_bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(img_bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
    evas_object_show(img_bg);
    elm_object_part_content_set(image_box, “elm.swallow.background”, img_bg);
    elm_box_pack_end(mbox, image_box);
    evas_object_show(image_box);

 

Is there anything wrong in my code? or Am I missing to use any APIs?

Thank you.

Written by