언어 설정

Menu
Sites
Language
Can't set width of label to match parent element

Hi there!

I have next code:

/* Conformant */
    ad->conform = elm_conformant_add(ad->win);
	elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW);
	elm_win_indicator_opacity_set(ad->win, ELM_WIN_INDICATOR_OPAQUE);
	evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND,
	EVAS_HINT_EXPAND);
	elm_win_resize_object_add(ad->win, ad->conform);
	evas_object_show(ad->conform);

/* Naviframe */
    ad->naviframe = elm_naviframe_add(ad->conform);
	elm_object_content_set(ad->conform, ad->naviframe);
	evas_object_show(ad->naviframe);

/* Scroller */
    ad->scroller = elm_scroller_add(ad->naviframe);
	evas_object_size_hint_weight_set(ad->scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(ad->scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
	elm_scroller_single_direction_set(ad->scroller, ELM_SCROLLER_SINGLE_DIRECTION_HARD);

	nav_it = elm_naviframe_item_push(ad->naviframe, "Habrahabr", NULL, NULL,
			ad->scroller, NULL);
	scroller = ad->scroller;

/* Content box */
    ad->box = elm_box_add(ad->scroller);
	elm_box_padding_set(ad->box, 0, 5);
	evas_object_size_hint_weight_set(ad->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(ad->box, EVAS_HINT_FILL, EVAS_HINT_FILL);
	elm_box_horizontal_set(ad->box, EINA_FALSE);
	elm_object_content_set(ad->scroller, ad->box);
	content_box = ad->box;

Eina_Iterator *iterator = eina_list_iterator_new(list);

EINA_ITERATOR_FOREACH(iterator, id) {
box = elm_box_add(content_box);
    	evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
		evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
		elm_box_horizontal_set(box, EINA_FALSE);

		title_text = elm_label_add(box);
		evas_object_size_hint_weight_set(title_text, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
		evas_object_size_hint_align_set(title_text, EVAS_HINT_FILL, EVAS_HINT_FILL);
		Eina_Strbuf * str = eina_strbuf_new();
		eina_strbuf_append_printf(str, "%s", id->title);
		elm_object_text_set(title_text, eina_strbuf_string_get(str));
		eina_strbuf_string_free(str);
		eina_strbuf_free(str);
		elm_label_line_wrap_set(title_text, ELM_WRAP_WORD);
		evas_object_show(title_text);
		elm_box_pack_end(box, title_text);

		description_txt = elm_label_add(box);
		evas_object_size_hint_weight_set(description_txt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
		evas_object_size_hint_align_set(description_txt, EVAS_HINT_FILL, EVAS_HINT_FILL);
		elm_object_text_set(description_txt, id->description);
		elm_label_line_wrap_set(description_txt, ELM_WRAP_WORD);
		evas_object_show(description_txt);
		elm_box_pack_end(box, description_txt);

		evas_object_show(box);
		elm_box_pack_end(content_box, box);

	}

My problem is that title_text and description_txt has huge text and labels goes beyond the screen.
How could I solve this problem?

Thanx!

Edited by: Alexey Bey on 06 2월, 2015

Responses

2 댓글
colin Rao

Hi, what's you list sample data as your source code, Enia_Iterator *iterator = eina_list_iterator_new(list); could you share here? 

colin Rao

I've test your code by using static temp data.

By defualt, if the text string is two long, the label will expand it's parent width, and the string always displaying in single line, you can horizontal scroll the screen to see the hidened string.

But, when I change the sequence of below two functions, it's works, the text of label will be wraped to fill the screen width.

        elm_label_line_wrap_set(description_txt, ELM_WRAP_WORD);
        elm_object_text_set(description_txt, id->description);

Seems, it's a bug of Label widget.