增加FireMonkey TSpeedButton图像的大小

时间:2016-02-19 09:25:15

标签: android ios delphi firemonkey delphi-xe8

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

1 个答案:

答案 0 :(得分:2)

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

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

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

    enter image description here

    1. 查找icon子项并在Object Inspector中更改其属性。例如,您可以更改Align(默认为Client)和WrapMode(默认为Center
    2. 第二种方式 - 在运行时执行此操作。将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. 中保存样式簿中的样式
      3. 在任何文本编辑器(例如Notepad ++)中打开此文件
      4. 查找下一个字符串
      5. object TLayout
          StyleName = 'cameratoolbutton'
          Visible = False
          TabOrder = 160
          FixedWidth = 44
          FixedHeight = 44
        
        1. 删除FixedXXX字符串并保存文件
        2. 将更改的文件加载到样式簿
        3. 注意2 :样式使用位图,所以如果您需要大/小图片,也许您应该使用自己的图片

相关问题