【问题标题】:Change gradient in ApplyStyleLookup在 ApplyStyleLookup 中更改渐变
【发布时间】:2014-10-23 02:47:29
【问题描述】:

我试图在运行时使用 ApplyStyleLookup 更改 TSpeedbutton 的渐变颜色,但由于某种原因,只有按钮的前三分之二会改变颜色。当我在设计时更改它时,我看到渐变的三个点。我在 TSpeedbuttons StyleLookup 中使用按钮样式。使用 Delphi XE6 Rad Studio。

谢谢。 添加了 8/29/14 我找到了更改渐变的方法,请参见下文。但我的问题是按钮样式有三个矩形,而我需要访问的是背景下的矩形 2。我需要什么才能访问它。

procedure TForm1.SpeedButton1ApplyStyleLookup(Sender: TObject);
var
  BckObject: TFmxObject;
begin
  BckObject := SpeedButton1.FindStyleResource('background');
  if Assigned(BckObject) and (BckObject is TRectAngle) then
  begin
    TRectAngle(BckObject).Fill.Gradient.Style := TGradientStyle.Linear;
    TRectAngle(BckObject).Fill.Gradient.Points.Points[0].Color := $FF0097A5;
    TRectAngle(BckObject).Fill.Gradient.Points.Points[0].Offset := 0.25;
    TRectAngle(BckObject).Fill.Gradient.Points.Points[1].Color := $FF0097F5;
    TRectAngle(BckObject).Fill.Gradient.Points.Points[1].Offset := 1.00;
  end;

end;

【问题讨论】:

  • 这会因风格而异,在任何人都可以尝试回答之前,您必须提供您正在使用的风格。另外,你为什么要使用TSpeedButton,然后将styleLookup设置为buttonstyle,然后使用TButton
  • 在 Stylelookup 中我选择了 buttonstyle,所以我不确定您指的是什么其他样式。我从第 2 版开始使用 Delphi,这是我第一次尝试使用 Delphi 制作 Android 应用程序,过去四年我一直在使用 Eclipse 开发 Android 应用程序。我使用 TSpeedbutton 是因为我不希望按钮在按下时获得焦点。

标签: delphi firemonkey delphi-xe6


【解决方案1】:

背景下的 rectangle2 (TRectAngle) 的 StyleName 属性为空白,通过在 StyleName 中输入名称并保存,我可以使用相同的方法访问 rectangle2: BckObject := SpeedButton1.FindStyleResource('myname');

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-20
    • 2019-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-03
    相关资源
    最近更新 更多