How to make image height same as label?

How to make image height same as label?

BY 04 Dec 2016 Native Application Development

Hi,

I have a horizontal box, which has LABEL and IMAGE next to each other.

I want the IMAGE to have the same height automatically as the LABEL (and keep the aspet ratio).

I cannot make it, IMAGE size always the min.size. of the image.

I want the image (smiley) have the same height as the label.

Current code:

        Evas_Object* boxLabel = elm_box_add(box);
        evas_object_size_hint_align_set(boxLabel, EVAS_HINT_FILL, 0.0);
        evas_object_size_hint_weight_set(boxLabel,EVAS_HINT_EXPAND,0.0);
        elm_box_align_set(boxLabel, 0.0, 0.0);
        elm_box_horizontal_set(boxLabel, EINA_TRUE);
        evas_object_show(boxLabel);

        Evas_Object* label = elm_label_add(boxLabel);
        elm_object_text_set(label, "hello world");
        evas_object_size_hint_align_set(label ,0.0,0.5);
        evas_object_size_hint_weight_set(label , 0.0, 0.0);
        evas_object_show(label );
        elm_box_pack_end(boxLabel,label );

        Evas_Object *image = elm_image_add(boxLabel);
        //Evas_Object *image = evas_object_image_filled_add(boxLabel); --> does not work
        elm_image_file_set(image, "............", NULL);
        evas_object_size_hint_min_set(image, 32, 32); // image always has this size
        evas_object_size_hint_align_set(image,0.0,0.5);
        evas_object_size_hint_weight_set(image, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);  //tried with _FILL, no change
        evas_object_image_filled_set(image, EINA_TRUE);  //this has no effect
        evas_object_show(image);
        elm_box_pack_end(boxLabel,image);

Is there a way to achieve this?
Basically, I don’t want to specify size for the image, “evas_object_resize()”, but the image height to be the same as the label height (which is based on the device resolution), and width should just adjusted according to the acpect ratio.

Written by