简体   繁体   English

移动FireMonkey中的自定义样式

[英]Custom styles in mobile FireMonkey

Used: Appmethod 1.14 二手货:Appmethod 1.14

I need to design an application with a custom style. 我需要设计具有自定义样式的应用程序。 Placing a TStyleBook on the form and double-clicking it opens the Style Designer but it is empty, so I need to load one of the *.fsf or *.style files shipped with Appmethod / RAD Studio. 将TStyleBook放置在窗体上并双击它会打开样式设计器,但它是空的,因此我需要加载Appmethod / RAD Studio附带的* .fsf或* .style文件之一。 I would like to make a design based on the standard Android and iOS design (the ones that are used in the IDE if no custom style applied), but where do I find the style files? 我想基于标准的Android和iOS设计(如果未应用自定义样式,则在IDE中使用的设计)进行设计,但是在哪里可以找到样式文件? My problem: There is an "AndroidLight.fsf" file which looks exactly like the default (hard coded?) Android design in the IDE. 我的问题:有一个“ AndroidLight.fsf”文件,看起来与IDE中的默认Android设计(硬编码?)完全一样。 I can modify it and it works in Android. 我可以对其进行修改,并且可以在Android中使用。 This is nice. 很好 But I can't use the same style for iOS (I need to use one single style for Android and iOS), because the App just freezes (if I use a TStyleBook) or shows me an error that the style cannot be loaded from resource (if I add it as a resource and load from there): 但是我无法为iOS使用相同的样式(对于Android和iOS,我需要使用一种样式),因为该应用只是冻结(如果我使用TStyleBook)或显示错误,表明无法从资源中加载样式(如果我将其添加为资源并从那里加载):

procedure TUserDataForm.FormCreate(Sender: TObject);
var
  Style: TFMXObject;
begin
  MainScroll := VertScrollBox1;

  {$IFDEF Android}
    // works
    Style := TStyleManager.LoadFromResource(HInstance, 'DSRAndroidIOS', RT_RCDATA);
  {$ENDIF}
  {$IFDEF iOS}
    // Can't load same style file
    Style := TStyleManager.LoadFromResource(HInstance, 'DSRAndroidIOS', RT_RCDATA);
  {$ENDIF}
  if Style <> nil then
    TStyleManager.SetStyle(Style);
end;

And I couldn't find any other *.style or *.fsf file shipped with Appmethod / RAD Studio, which looks like the standard iOS 7 design in the IDE. 而且我找不到与Appmethod / RAD Studio一起提供的其他* .style或* .fsf文件,它看起来像IDE中的标准iOS 7设计。 I could try to start adding my own style-sections in the Style Designed, but how do I know which names to use and how the style hirarchy is structured? 我可以尝试在“样式设计”中添加自己的样式部分,但是如何知道要使用的名称以及样式层次结构的结构? Is there an overview some where? 在哪里有概述?

I found 6 files without a file extension in the folder "C:\\Program Files (x86)\\Embarcadero\\Studio\\14.0\\bin\\ios\\". 我在文件夹“ C:\\ Program Files(x86)\\ Embarcadero \\ Studio \\ 14.0 \\ bin \\ ios \\”中找到了6个没有文件扩展名的文件。 They seem to be binary style files (opened with a Hex editor) but I can't load them in the StyleDesiger, error: "Error reading TSubImage.SourceRect.LeftI: Property SourceRect.LeftI does not exists" (or similar - translated from german). 它们似乎是二进制样式文件(已用十六进制编辑器打开),但我无法将它们加载到StyleDesiger中,错误:“读取TSubImage.SourceRect.LeftI时出错:属性SourceRect.LeftI不存在”(或类似的翻译自德语)。

Edit: Ok, I have the styles now. 编辑:好的,我现在有样式。 I extracted them myself from a compiled mobile FireMonkey project with iOS as target platform. 我自己从一个以iOS为目标平台的移动FireMonkey项目中提取了它们。 Used an hex editor for that. 为此使用了十六进制编辑器。 But I would like to know if the styles are stored somewhere else maybe? 但是我想知道样式是否存储在其他地方?

You can get the original styles via the Bitmap Style Designer that is bundled with Delphi. 您可以通过Delphi附带的位图样式设计器获得原始样式。 You'll find the link on the Tools menu in the IDE. 您可以在IDE中的“工具”菜单上找到链接。

Once opened click the dropdown next the the File Open icon. 打开后,单击“文件打开”图标旁边的下拉菜单。 You'll see the available styles listed. 您会看到列出的可用样式。 Click one to open, then select File|Save As and select Save as type: FireMonkey Style. 单击一个以打开,然后选择“文件” |“另存为”,然后选择“另存为”类型:FireMonkey样式。

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

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