语言

Menu
Sites
Language
how to image element into a box

Evas_Object *image = elm_image_add(box);

evas_object_show(image);
elm_box_pack_end(box, image);

char image_path[] = "opt/usr/apps/org.example.bai1/shared/res/myfirstproject.png";
elm_image_file_set(image, image_path, NULL);

is that image_path wrong? i don't know how to get image's source. can someone help me?

响应

5 回复
woochan lee

Hello. my sample code below.

Evas_Object *img = elm_image_add(bx);
snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
elm_image_file_set(img, buf, NULL);
evas_object_size_hint_weight_set(img, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(img, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(bx, img);
evas_object_show(img);

You need to call the evas_object_show API for it :)

More information about evas_object_size_hint_XXX APIs please refer this below link.

 https://developer.tizen.org/dev-guide/2.3.0/org.tizen.native.mobile.apireference/group__Evas__Object__Group__Size__Hints.html

Jakub Wiśniewski

I have a problem. I have good file path (I logged it and confirmed in connection explorer), and add label with text below image and image is not visible but the text label is. Should I load image to application memory also?

    Evas_Object *data_content = elm_box_add(content);
    elm_box_padding_set(data_content, 0, 0);
	evas_object_size_hint_weight_set(data_content, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(data_content, EVAS_HINT_FILL, EVAS_HINT_FILL);
	elm_box_horizontal_set(data_content, EINA_FALSE);
	evas_object_show(data_content);
	elm_box_pack_end(content, data_content);

	char *path = app_get_resource_path();
	char imagePath[PATH_MAX];
	snprintf(imagePath, sizeof(imagePath), "%s%s", stradd(path, "images/"), image_name);

	Evas_Object *image = elm_image_add(data_content);
	elm_image_file_get(image, imagePath, NULL);
	evas_object_size_hint_weight_set(image, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(image, EVAS_HINT_FILL, EVAS_HINT_FILL);
	evas_object_show(image);
	elm_box_pack_end(data_content, image);

    Evas_Object *value_label = elm_label_add(data_content);
	evas_object_size_hint_weight_set(value_label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(value_label, EVAS_HINT_FILL, 0.5);
	elm_label_line_wrap_set(value_label, ELM_WRAP_WORD);
	elm_object_text_set(value_label, text_with_aligment("center", text_with_size(40, value)));
	evas_object_show(value_label);
	elm_box_pack_end(data_content, value_label);

 

Shaswati Saha

You may go through the create_page() function of the GalleryUI sample app. You'll find the similar implementation there.

GEUNSOO KIM

I think you have used "elm_image_file_get()" instead of "elm_image_file_set()" on the above code..

Jakub Wiśniewski

Yes you are right! But that did not help (well it definetly help but it wasn't the only reason :) ) I also had to set no scale:

elm_image_file_set(image, imagePath, NULL);  
elm_image_no_scale_set(image, EINA_TRUE);