简体   繁体   English

Delphi XE5 Android TButton颜色

[英]Delphi XE5 Android TButton colors

I need change color of 50 buttons in one form. 我需要以一种形式更改50个按钮的颜色。 Every button another color and color want to set by code(no design editor). 每个按钮都需要通过代码设置其他颜色和颜色(无设计编辑器)。

It is firemonkey mobile application. 它是firemonkey移动应用程序。

By my opinion, without making your own button that doesn't use FMX styles completely (which would break multiplatform compatibility if you are looking forward to support multiple platforms with their native styles), you may apply some filter on top of each of those buttons but on some styles this may cause the text not to be visible, implementing your own filter might get you the desired result: 以我的观点,如果没有制作自己的按钮而不完全使用FMX样式(如果您希望以其本机样式支持多个平台,那么这将破坏多平台兼容性),则可以在每个按钮之上应用一些过滤器但是在某些样式上,这可能会导致文本不可见,实现自己的过滤器可能会为您提供所需的结果:

Effect:=TFillRGBEffect.Create(Self);
Effect.Color:=$80FF0000;
Effect.Parent:=SomeButton;

Another way would be to take advantage of TColorButton with TText on top of it, but this way the entire button won't be filled with your color, but you can modify default/custom style for each platform in order to get what you need (this indeed needs to be done in the designer but you would have to create just one style for each platform you need to support and not 50 for each button): 另一种方法是利用TColorButton并在其顶部使用TText ,但是这样就不会用颜色填充整个按钮,但是您可以修改每个平台的默认/自定义样式以获取所需的内容(这确实需要在设计器中完成,但是您只需要为需要支持的每个平台创建一种样式,而不必为每个按钮创建50种样式):

Button:=TColorButton.Create(Self);
Button.Color:=$80FF0000;
Text:=TText.Create(Button);
Text.Parent:=Button;
Text.Align:=TAlignLayout.alClient;
Text.Text:='Hello';
Text.HitTest:=false;
Button.ClipChildren:=true;
Button.Parent:=Self;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM