【发布时间】:2016-02-19 09:25:14
【问题描述】:
在跨平台应用程序的表单上使用FireMonkey TspeedButton 时,将属性StyleLookup 设置为使用cameratoolbutton 是否有任何方法可以更改此图像的大小,我似乎无法找到任何东西。
【问题讨论】:
标签: android ios delphi firemonkey delphi-xe8
在跨平台应用程序的表单上使用FireMonkey TspeedButton 时,将属性StyleLookup 设置为使用cameratoolbutton 是否有任何方法可以更改此图像的大小,我似乎无法找到任何东西。
【问题讨论】:
标签: android ios delphi firemonkey delphi-xe8
至少有两种方法可以做到这一点,但都基于使用样式书。
首先,最简单的方法 - 在样式簿中编辑 cameratoolbutton 样式:
Structure面板中的cameratoolbutton项目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的大小,因为当你运行程序时,它的大小会返回到硬编码的值。如果你需要这个,你必须做下一个解决方法:
.style 文件中object TLayout StyleName = 'cameratoolbutton' Visible = False TabOrder = 160 FixedWidth = 44 FixedHeight = 44
FixedXXX 字符串并保存文件注意2:样式使用位图,所以如果你需要大/小图片,也许你应该使用自己的图片
【讨论】: