原文 :http://blogs.embarcadero.com/sarinadupont/2013/10/16/how-to-load-custom-styles-at-runtime/

How to load custom styles at runtime

During my session at CodeRage, I briefly talked about how to load custom styles at runtime. I wanted to elaborate on this topic and provide some detailed steps.

In this example, we are creating a mobile app for iOS and Android that uses the ‘Jet’ Premium Style. I added both styles via the resources dialog in the IDE and used the TStyleManager.LoadFromResource method to load either style at runtime.

When loading custom styles at runtime using the steps below, you don’t see the style at design time.

The first step is to add both styles to resources via ‘Project->Resources and Images’ in the IDE.

Click on ‘Add’, browse to the location of your style (i.e. C:\PremiumPack\iOS) and select the style (i.e. iOSJet.style). Then click on ‘Open’.

Change the name of the Resource Identifier to match the string in your code.

I then created the following OnCreate event for my Form:

procedure TForm1.FormCreate(Sender: TObject);
var
Style: TFMXObject;
begin
Style := nil;
{$IFDEF IOS}
Style := TStyleManager.LoadFromResource(HInstance, ‘iOSJet’, RT_RCDATA);
{$ENDIF}
{$IFDEF ANDROID}
Style := TStyleManager.LoadFromResource(HInstance, ‘AndroidJet’, RT_RCDATA);
{$ENDIF}
if Style <> nil then
TStyleManager.SetStyle(Style);
end;

At runtime, on my iOS device, I see the iOSJet style, and on my Android device, I see the AndroidJet style.

Sincerely,

Sarina

How to load custom styles at runtime (不会翻译,只有抄了 )的更多相关文章

  1. vue的采坑之旅--vue-cli脚手架loader重复--Invalid CSS after "...load the styles": expected 1 selector or at-rule

    在使用scss是可能会添加loader,例如 { test: /\.scss$/, use: ['style-loader', 'css-loader', 'sass-loader'], } 然而当使 ...

  2. Could not load file using Ranorex runtime : General Questions

    如果你将编译好的bin文件夹复制到另一个未安装Ranorex程序的电脑上运行遇到如下错误信息 Could not load file or assembly 'Ranorex.Core, Versio ...

  3. 升级tensorflow1.0到1.3,报错ImportError: libcudnn.so.6: cannot open shared object file: No such file or directory Failed to load the native TensorFlow runtime.

    先定位问题,发现在 /usr/local/cuda/include/ /usr/local/cuda/lib64/ 下面只有 libcudnn.so.5 因此,只要下载cudnn6.*版本的文件分别覆 ...

  4. Net Core 5.0 部署IIS错误-500.31-Failed to load ASP.NET Core runtime

    Windows Server 2008 R2不支持.net core 3.0版本及以后更新的各个版本. 面对如上图提示,第一想到的就是服务器安装的SDK或者hosting版本有问题,第一时间检查了安装 ...

  5. Spring Data JPA教程, 第三部分: Custom Queries with Query Methods(翻译)

    在本人的Spring Data JPA教程的第二部分描述了如何用Spring Data JPA创建一个简单的CRUD应用,本博文将描述如何在Spring Data JPA中使用query方法创建自定义 ...

  6. Happening in delphi world

    Happy New Year! Delphi XE5 Update 2 Recent VCL enhancements New product features for old product use ...

  7. 理解Objective-C Runtime(四)Method Swizzling

    Objective-C对象收到消息之后,究竟会调用何种方法需要在运行期间才能解析出来.那你也许会问:与给定的选择子名称相应的方法是不是也可以在runtime改变呢?没错,就是这样.若能善用此特性,则可 ...

  8. Cocos Creator 资源加载流程剖析【三】——Load部分

    Load流程是整个资源加载管线的最后一棒,由Loader这个pipe负责(loader.js).通过Download流程拿到内容之后,需要对内容做一些"加载"处理.使得这些内容可以 ...

  9. check whether the crystal report runtime is exists 检查crystalreport运行时是否存在

    1. Try Dim rptDoc As New CrystalDecisions.CrystalReports.Engine.ReportClass() Dim rptView As New Cry ...

随机推荐

  1. Fastjson-fastjson中$ref对象重复引用问题:二

    import java.util.ArrayList; import java.util.List; import com.alibaba.fastjson.JSON; import com.alib ...

  2. linux iso 下载地址

    Centos 5.3  下载地址: http://www.karan.org/mock/5.3/CentOS-5.3-i386-bin-1to6.torrent http://www.karan.or ...

  3. MongoDB AUTH结果验证

      创建超级管理员和普通用户 #创建超级管理员 super db.createUser( { user: "super", pwd: "super", role ...

  4. 批量压缩 css js 文件 包含多个文件 自动识别

    注意事项  css 注释压缩不会造成影响      因为是块注释     当然也可以选择去注释压缩 js 带注释压缩  要注意注意 注意  //行注释会造成 压缩后的代码在一行 导致注释后的代码都失效 ...

  5. linux软件管理 源码包

    源码包安装位置 安装在指定位置当中,一般是 /usr/local/软件名/ ​ 注意: 需要指定安装路劲为了便于卸载,因为源码包的是没有卸载命令的,它的的卸载方式就是把对应安装文件夹删除了. 所以如果 ...

  6. 面向对象编程其实很简单--python面向对象(初级篇)

    出处:http://www.cnblogs.com/wupeiqi/ 概述 面向过程:根据业务逻辑从上到下写垒代码 函数式:将某功能代码封装到函数中,日后便无需重复编写,仅调用函数即可 面向对象:对函 ...

  7. guava-retrying 源码解析(等待策略详解)

    一.等待策略相关类: 1.等待策略接口:WaitStrategy接口 该接口只有一个方法,就是返回尝试失败之后,下一次尝试之前的等待时间.long computeSleepTime(Attempt f ...

  8. vm虚拟机下ubuntu连接上ssr

    第一步: 第二步: 第三步: 第四步: 完成!

  9. 剑指Offer 41. 和为S的连续正数序列 (其他)

    题目描述 小明很喜欢数学,有一天他在做数学作业时,要求计算出9~16的和,他马上就写出了正确答案是100.但是他并不满足于此,他在想究竟有多少种连续的正数序列的和为100(至少包括两个数).没多久,他 ...

  10. ASP.NET之使用Ajax实现页面异步刷新(无需刷新整个页面)

    目前在使用ASP.NET技术做毕业设计,但是关于网页中的各种配置我到现在还不是很清楚,正在努力进化... 一般情况下,新建网页页面的话,应该为.aspx后缀的文件,建好之后对应一个同名的.cs文件,属 ...