Question
I need to display color indicators for selected colors in my Tizen mobile application. These indicators should appear in Genlist items, detail views, and dialogs.
I've explored two approaches but encountered issues:
- Using Elm_Bg: The colored background doesn't render unless I specify minimum size
- Using ColorSelector's circle widget: It shows but I can't change its color
Here are my implementation attempts:
Colored Square Approach:
static Evas_Object* gl_content_get_cb(void* data, Evas_Object* obj, const char* part) {
if (!strcmp(part, "elm.swallow.end")) {
Evas_Object* bg = elm_bg_add(obj);
elm_bg_color_set(bg, 66, 162, 206);
return bg;
}
}
Circle Widget Approach:
static Evas_Object* gl_content_get_cb(void* data, Evas_Object* obj, const char* part) {
if (!strcmp(part, "elm.swallow.end")) {
Evas_Object* layout = elm_layout_add(obj);
elm_layout_theme_set(layout, "colorselector", "item", "default");
return layout;
}
}
What is the recommended way to implement such color indicators in Tizen native applications?
Answer
Problem Understanding
The user needs to display color indicators in various UI components of a Tizen mobile application. The main challenges are:
- Getting basic color indicators to render properly
- Finding the most appropriate component for this purpose
Solution Methods
-
Using Elm_Bg with Proper Size Hints
- The background object requires explicit size hints to render
- Solution code:
Evas_Object* bg = elm_bg_add(obj); elm_bg_color_set(bg, 66, 162, 206); evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_min_set(bg, ELM_SCALE_SIZE(24), ELM_SCALE_SIZE(24)); evas_object_size_hint_aspect_set(bg, EVAS_ASPECT_CONTROL_BOTH, 1, 1); return bg;
-
Alternative Approach Using Layouts
- For more complex indicators, consider using custom layouts
- This provides more control over appearance and behavior
Additional Tips
- When using Elm_Bg, remember that size hints are mandatory for proper rendering
- For consistent appearance across devices, use ELM_SCALE_SIZE for dimension values
- Consider accessibility requirements when choosing colors