Languages

Menu
Sites
Language
background color for the scroller

In my app I need to scroll through a number of custom objects.

So, my solution was to have a scroller widget which contains box widget with a number of custom layouts. I works well.

Currently I need to change a background color for this screen.

I tried to use background widget for scroller and for box, but it doesn't work.

Do you have any idea how to change background color for scroller?

Thanks
 

Responses

8 Replies
Jin Yoon

Actullay, you can use elm_layout like below.

 

You can use two parts for setting your background color.The first part named 'bg' has to be set with evas_object_rectangle or elm_image(that has colors).The second part named 'content' has to be set with your scroller.These kinds of codes are normally used on the tizen apps.Best regards, Jin.

Jin Yoon

group {
name: "your_group";
parts {
part {
name: "bg";
type: SWALLOW;
scale: 1;
mouse_events: 1;
description {
state: "default" 0.0;
rel1 { relative: 0.0 0.0; }
rel2 { relative: 1.0 1.0; }
visible: 0;
}
}
part {
name: "content";
type: SWALLOW;
scale: 1;
mouse_events: 1;
description {
state: "default" 0.0;
align: 0.5 0.0;
rel1 { relative: 0.0 0.0; to, "content_bg";}
rel2 { relative: 1.0 1.0; to, "content_bg";}
visible: 1;
}
}

 

I'm sorry. I cannot add these codes because of spam filter... :(

So I try again...

Alex Dem

Hi,
I tried to set background for scroller programmatically but I was not able.
I tried to use evas_object_color_set but this method fill whole scroller with placed on it child objects (content).
Looks like it possible only with EDC.
Per my opinion if simple way like elm_bg_color_set could be applicable some for other widgets (not only for background widget) - it could be comfortable for developers.
Alexey.

Alex Dem

Hi all, in additional
I just want ask, how could be added background color for scroller wich was created this way:

    Evas_Object *scroller, *layout_inner;
    Evas_Object *nf = data;

    scroller = elm_scroller_add(nf);
    elm_object_style_set(scroller, "effect");
    elm_scroller_policy_set(scroller,ELM_SCROLLER_POLICY_ON,ELM_SCROLLER_POLICY_ON);
    evas_object_show(scroller);

    elm_naviframe_item_push(nf, "Ellipsis", NULL, NULL, scroller, NULL);

    layout_inner = create_labels(nf);
    elm_object_content_set(scroller, layout_inner);

Is there simple way? I did not find.
Alexey.

Vikram

Is it possible to use elm_bg_add() object to be the only child of your scroller, and let all the scroller origin content to be the overlay content of the bg object. Then, you can set the bg color/image easily as you want.

Sample code:

    Evas_Object *main_box = elm_box_add(ad->conform);
    evas_object_size_hint_weight_set(main_box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(main_box, EVAS_HINT_FILL, EVAS_HINT_FILL);
    evas_object_show(main_box);

    /* Creating a background */
    Evas_Object *bg = elm_bg_add(main_box);
    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL);

    /* Use red color for background */
    //elm_bg_color_set(bg, 0xFF, 0x00, 0x00);
    /* Set a file on the disk as background image */
    elm_bg_file_set(bg, "/opt/usr/apps/org.tizen.test/res/images/mango.jpg", NULL);
    /* Set an edje group as background image */
    //elm_bg_file_set(bg, "/path/to/the/edje", "edje_group");

    elm_bg_option_set(bg, ELM_BG_OPTION_STRETCH);
    evas_object_show(bg);


    /* Title Label*/
    Evas_Object *label = elm_label_add(main_box);
    elm_object_text_set(label, "Title Label");
    //evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
    evas_object_show(label);

    elm_object_part_content_set(bg, "overlay", label);
    elm_box_pack_end(main_box, bg);

 

Jin Yoon

This is just a question.

I've checked the repo. "git://review.tizen.org/framework/uifw/efl-theme-tizen", branch 'tizen_2.3'.

But I cannot find "overlay" part of bg.edc.

If the bg winset doesn't have a part named 'overlay', then elm_object_part_content_set() will be failed.

So, in this case, label is just upper than the bg.

(But it looks same as it is content_set)

Best regards, Jin.

Vikram

Hi, thanks! actually, I am not check the edje source code. above sample code just from the IDE help doc. 

As the related section:

Background Widget

Jin Yoon

Oh, I see.

Thank you for your answer. :)