语言

Menu
Sites
Language
how to change button background color?

how to change button background color in tizen version 2.4?
old versions(under 2.3) has not use default background color. but new version has background cyan color. 
I want to make clear the background color of the button.
What should I do?

编辑者为: hayden kang 14 7月, 2015

响应

8 回复
Vikram

Hi,

I don't face such direct way to change the button's background color. 

You can try to use the image button as a workaround.

Another, as button is inherit from the layout, possible you can define a customer style for button, example an edc group with bg part and text part. Then use the api elm_layout_file_set() to set the customized style on the button.

Additional info, regarding how to customizing widgets, https://developer.tizen.org/documentation/guides/native-application/ui/ui-control/widget-preferences#customize

 

hayden kang

i'm already use image button, but there are same problem. 

anyway, i will try another way. thanks for your answer.

Phil rzr

I am crosslinking it to :

http://stackoverflow.com/questions/24730499/how-to-add-background-to-elementaryefl-widget

Also villains from IRC asked " Could there be a *_user_style_push() function added to buttons and labels, like entry has?"

Eugene Kurzberg

Unfortunately it is impossible to change the color of the default button on Tizen 2.4 because button color is hardcoded in the default button theme. This issue will be fixed in Tizen 3.0 by introducing color_classes into the theme which will allow you to use edje_object_color_class_set() API (or similar new API) to change colors used in standard widget. On Tizen 2.4 however you need to implement your own button style for this. This can be done by implementing EDC group named "elm/button/base/your_button", adding your extension to the theme:

elm_theme_extension_add(nullptr, "path_to_your_theme.edj");

and setting your style to the button:

Evas_Object *button = elm_button_add(parent);
elm_object_style_set(button, "your_button");

Implementing your own style is not a simple task. You have to be familiar with EDC and also there are some undocumented features that your implementation should have such as a program to pass the "clicked" event from the to the widget:

program {
	name: "clicked";
	signal: "mouse,clicked,*";
	source: "*";
	action: SIGNAL_EMIT "elm,action,click" "";
}

If you are really going to implement your own style you should get access to Gerrit (if you don't have it yet) to be able to explore how the default theme is implemented (see Tizen 2.4 or Tizen 3.0 theme repository).

Luzian Scherrer

Could you show a quick example how to use the edje_object_color_class_set() API to change the background color of a button in a native Tizen app? I'm using a two button circular popup with the content/circle/buttons2 style but I have not been able to figure out how to change the background color of the two buttons (individually).

Eugene Kurzberg

Please see the code snippet I added implementing a custom button style.

Jakub Wiśniewski

But, the component does not have rounded corners and does not have borders. I have added borders to your code snippet, but I cant get rounded corners.

Phil rzr

Thanks, chaging theme is the more logicial way to change a widget color, I got it confirmed from EFL upstream  developer.