Wearable native

Background

This feature is supported in wearable applications only.

The background component can be used to set a solid background decoration to a window or to a container object. It works like an image, but has some background specific properties, for example it can be set to a tiled, centered, scaled, or stretched mode. There are no specific signals relative to background object.

Figure: Red color background

Red color background

Figure: Background hierarchy

Background hierarchy

Adding a Background Component

A background is created with the elm_bg_add() function.

Evas_Object *bg, *parent;

// Create a background
bg = elm_bg_add(parent);

Changing the Color of the Background

You can set the color of the background with the elm_bg_color_set() function. The following example sets the background color to red.

Evas_Object *bg;

// Use red color for background
elm_bg_color_set(bg, 0xFF, 0x00, 0x00);

Changing the Image of the Background

It is also possible to set an image or an Edje group as a background using the elm_bg_file_set() function. The display mode of the image in the background can be chosen with elm_bg_option_set(), where the following modes are available:

  • ELM_BG_OPTION_CENTER: center the background image.
  • ELM_BG_OPTION_SCALE: scale the background image, retaining aspect ratio.
  • ELM_BG_OPTION_STRETCH: stretch the background image to fill the UI component's area.
  • ELM_BG_OPTION_TILE: tile the background image at its original size.
Evas_Object *bg;

// Set a file on the disk as a background image
elm_bg_file_set(bg, "/path/to/the/image", NULL);
// Set an Edje group as a background image
elm_bg_file_set(bg, "/path/to/the/edje", "edje_group");
elm_bg_option_set(bg, ELM_BG_OPTION_STRETCH)

Using Overlay

An overlay can be set using the overlay part name.

elm_object_part_content_set(bg, "overlay", over);

Here, the overlay is an Edje object that is displayed on top of the current background object.

Note
Except as noted, this content is licensed under LGPLv2.1+.
Go to top