Mobile native

Background

This feature is supported in mobile 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.

For more information, see the Background API.

Figure: Red color background

Red color background

Figure: Background hierarchy

Background hierarchy

Adding a Background Component

To create a background, use 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 the elm_bg_option_set() function. 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

To set an overlay, use the overlay part name. In the following example, the overlay is an Edje object that is displayed on top of the current background object.

elm_object_part_content_set(bg, "overlay", over);
Note
Except as noted, this content is licensed under LGPLv2.1+.
Go to top