【问题标题】:Increase size of FireMonkey TSpeedButton image增加 FireMonkey TSpeedButton 图像的大小
【发布时间】:2016-02-19 09:25:14
【问题描述】:

在跨平台应用程序的表单上使用FireMonkey TspeedButton 时,将属性StyleLookup 设置为使用cameratoolbutton 是否有任何方法可以更改此图像的大小,我似乎无法找到任何东西。

【问题讨论】:

    标签: android ios delphi firemonkey delphi-xe8


    【解决方案1】:

    至少有两种方法可以做到这一点,但都基于使用样式书。

    首先,最简单的方法 - 在样式簿中编辑 cameratoolbutton 样式:

    1. 将样式加载到样式簿并打开
    2. 滚动到Structure面板中的cameratoolbutton项目

    1. 找到icon 子项并在Object Inspector 中更改它的属性。例如,您可以更改Align(默认为Client)和WrapMode(默认为Center

    第二种方式 - 在运行时执行。将OnApplyStyleLookup 事件处理程序添加到按钮并编写代码以使用样式项:

    procedure THeaderFooterForm.btn2ApplyStyleLookup(Sender: TObject);
    var
      obj: TFmxObject;
    begin
      obj:=TFmxObject(Sender).FindStyleResource('icon'); // use StyleName of inner object (see prev. picture)
      if Assigned(obj) and (obj is TStyleObject) then // TStyleObject is class of "icon"  (see prev. picture)
        TStyleObject(obj).WrapMode:=TImageWrapMode.Stretch;
    end;
    

    注意1:默认情况下,你不能改变cameratoolbutton的大小,因为当你运行程序时,它的大小会返回到硬编码的值。如果你需要这个,你必须做下一个解决方法:

    1. 将样式簿中的样式保存到 .style 文件中
    2. 在任何文本编辑器(例如 Notepad++)中打开此文件
    3. 查找下一个字符串
    object TLayout
      StyleName = 'cameratoolbutton'
      Visible = False
      TabOrder = 160
      FixedWidth = 44
      FixedHeight = 44
    
    1. 删除FixedXXX 字符串并保存文件
    2. 将更改的文件加载到样式簿

    注意2:样式使用位图,所以如果你需要大/小图片,也许你应该使用自己的图片

    【讨论】:

    • 事件处理方式似乎不适用于 Delphi 11,它一直显示一个小版本的图标
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-10-03
    • 1970-01-01
    • 1970-01-01
    • 2017-04-22
    • 2019-03-11
    • 2013-11-28
    • 2016-06-13
    相关资源
    最近更新 更多