语言

Menu
Sites
Language
how to make the button size to fit display button text

Hi, 

Is there anyway to fully show the text on the button automatily?  or how the set the button size to put the all button text properly.

响应

7 回复
colin Rao

Hi,

try evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);

Palitsyna

Hello,

maybe evas_object_size_hint_align_set() will be suitable for you, as said colin Rao. You can read about this in documentation:

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

You can also find some examples here:

https://developer.tizen.org/dev-guide/native/2.3.0/org.tizen.mobile.native.appprogramming/html/tutorials/ui_tutorial/uilayout_tutorial.htm

 

Regards,

Svetlana Palitsyna 

Jean Yang

Thanks all, just for simple, set the button style for contact is also ok.

Zoltan Puski

Hi,

I am also facing this problem:

  • If I create a "default" button, it's size is some minimal, the text is not visible.
  • If I call elm_object_style_set(button,"contacts"); , then button size is adjusted automatically, but it changes the color to dark blue - I want to have the standard default Tizen button color.
  • If I use the evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL); it will expand to full screen width - that is also not good.

I want to have the "contacts" style behavior (auto size adjustment to minimum where text is visible), but with the default style?
Is that possible?

 

Mango Bar

Look at the following screenshot. Here i implement all the button styles.

http://imgur.com/a/E543I

Only "bottom" style button color is dark blue. All other style colors are default Tizen button color including "default" and "contacts" style which you want. As you said, "contacts" style button color is changed to dark blue, i think you did something wrong with style name.

Check my  code of "default" style and "contacts" style 

        Evas_Object *contact_style_button = elm_button_add(ad->conform);
	evas_object_size_hint_weight_set(contact_style_button,EVAS_HINT_EXPAND,EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(contact_style_button,0.5,0.5);
	elm_object_style_set(contact_style_button,"contacts");
	elm_object_text_set(contact_style_button,"Contacts Style!");
	elm_box_pack_end(box,contact_style_button);
	evas_object_show(contact_style_button);


	Evas_Object *default_style_button = elm_button_add(ad->conform);
	evas_object_size_hint_weight_set(default_style_button,1.0,1.0);
	evas_object_size_hint_align_set(default_style_button,-1.0,-1.0);
	elm_object_style_set(default_style_button,"default");
	elm_object_text_set(default_style_button,"Default Style!");
	elm_box_pack_end(box,default_style_button);
	evas_object_show(default_style_button);
Zoltan Puski

For me "contacts" is always dark blue. Using your code (only change: default button height align hint from FILL (-1) -> 0.0), see:

http://oi64.tinypic.com/svpdvr.jpg

I am using 2.4 Windows Emulator (both HVGA+WVGA)

Zoltan Puski

Ok, I tested on a real device (via remote testlab), and there it is normal.

So it's an Emulator issue only.