Search code examples
ctizentizen-wearable-sdk

Tizen native wearable - how to add text label auto line break?


I want to show a full line of long text in a label. But when it is small in character numbers It can show it in full. But when the character number grows it shows some part of the texts. Even if I add size to it. It can show line break with html formats but I will perform character operation with network calls, so instead of checking individual characters or keeping track of numbers it will be better if it can add auto line break at the end of screen and show all the texts on screen.

Here's code for label:

    ad->label = elm_label_add(ad->conform);
elm_object_text_set(ad->label, "<align=center>Hello Tizen , line is cut offfffffffffffff.</align>");
//elm_object_text_set(ad->label, "<align=center>Hello Tizen <br>testing br</align>");
evas_object_size_hint_weight_set(ad->label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
//elm_object_content_set(ad->conform, ad->label);
evas_object_move(ad->label, 20, 100);
evas_object_resize(ad->label, 300, 300);
evas_object_show(ad->label);

How to add auto line break?


Solution

  • Try using elm_label_line_wrap_set API.

    elm_label_line_wrap_set(ad->label, ELM_WRAP_MIXED);

    See the API reference below.

    void elm_label_line_wrap_set ( Elm_Label *obj,
                                   Elm_Wrap_Type wrap 
                                 )  
    

    Control the wrapping behavior of the label.

    By default no wrapping is done. Possible values for wrap are: ELM_WRAP_NONE - No wrapping ELM_WRAP_CHAR - wrap between characters ELM_WRAP_WORD - wrap between words ELM_WRAP_MIXED - Word wrap, and if that fails, char wrap

    https://docs.tizen.org/iot/api/5.0/tizen-iot-headed/group__Elm__Label.html#ga60a1dad4d49a3aea31ced12e30d0b815