Using FireMonkey Layouts
FireMonkey has many layout controls to choose from. Come learn the differences and how to use them to create dynamic, multi-platform user interfaces.
FireMonkey Layouts with Delphi
FireMonkey Layouts with C++Builder
Understanding and using FireMonkey Layouts
FireMonkey and the FireUI makes it easy to build one form to rule all the platforms. Combining layout controls and making use of Anchors, Alignment, Padding and Margins it is easy to make one form that looks and works great on all platforms.
Anchors
- Position relative to one or more edge(s) of parent:
- Top
- Bottom
- Left
- Right
- Default is Top, Left
- Moves with parent resize
- Each control has 0 to 4 anchors
Alignment
- Aligns control within parent, setting anchors, size and position.
- Default is None.
- Anchor and fill along edge:
- Top, Bottom, Left, Right
- Fill parent, but preserve aspect ratio:
- Fit, FitLeft, FitRight
- Fill along one side of the parent (priority over other edge alignments):
- MostBottom, MostTop, MostLeft, MostRight
- Resize only on one axis (width or height)
- Vertical, VertCenter, Horizontal, HorzCenter
- Miscellaneous
- Client – Fills client area, less other children
- Center – No resize, just centered
- Contents – Fills client area, ignoring other children
- Scale – resizes and moves to maintain the relative position and size
Spacing – Margins and Padding
TFlowLayout
- Arrange child controls like words in a paragraph
- Controls arranged in order added to layout
- Use “Move to Front” or “Send to Back” to reorder
- Use TFlowLayoutBreak for forced line break
TGridLayout
- Arranges child controls in a grid of equal sizes
- Controls flow through grid as parent resizes
- Use ItemWidth and ItemHeight properties
- Customize margins of individual controls
TGridPanelLayout
- Creates a grid of specified rows and columns
- Does not change the anchor or size of child
- Each cell can contain 1 child control
- You set the Height, Width, Align, and Anchors of children
- Controls can span multiple cells
TScaledLayout
- Stretches child controls as it is resized at runtime
- Doesn’t respect aspect ratios of controls
- Set the Align of the TScaledLayout to Fit to maintain aspect ratio
- Some styles look better zoomed than others. The font grows – it is not a bitmap scale.
- Has properties for OriginalWidth and OriginalHeight – Compare to Width and Heightto determine scaling.
TScrollBox
- Allows children to take up more space than parent
- Usually anchored to Client
- Only anchor children to Top & Left (default)
- Scroll to see additional children
- See also: TVertScrollBox, THorzScrollBox,TFramedScrollBox and TFramedVertScrollBox
TTabControl
- Control to group child controls into tabs
- Tabs are in a stack with one visible at a time
- TabPosition := PlatformDefault to use platform default behavior
- TabPosition := None to hide navigation
- Use TTabChangeAction to animate transitions
Frames
- Reusable pieces of User Interface
- Includes
- The layout
- All the event handlers
- All the code in the unit
- Includes
- Create 1 or more Frames, then reposition based on current layout
- Examples:
- In TTabControl for phone
- Side-by-side for Tablet
- Examples:
TMultiView
- One super panel with multiple modes
- Supported modes
- PlatformDefault
- Drawer
- NavigationPane
- Panel
- Popover
- Custom
- Point to MasterPane, DetailPane and definable MasterButton
- PlatformDefault adapts to platform and orientation
- Custom supports user defined layout and behavior
Learning Resources
- FireMonkey Layout Strategies
- Layours
- Related technologies
- More layout options
- Previous Video Replays
ScaledLayout Helper
The AbsoluteToLocal and LocalToAbsolute for TScaledLayout don’t handle the scaling. I’ve created a class helper that adds new methods for dealing with scaling.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
{ TScaledLayoutHelper - interface } type TScaledLayoutHelper = class helper for TScaledLayout function LocalToAbsoluteScaled( const Point: TPointF): TPointF; function AbsoluteToLocalScaled( const Point: TPointF): TPointF; end ; { TScaledLayoutHelper - implementation } function TScaledLayoutHelper . AbsoluteToLocalScaled( const Point: TPointF): TPointF; begin Result . X := Self . Position . X + Point . X * Self . Width / Self . OriginalWidth; Result . Y := Self . Position . Y + Point . Y * Self . Height / Self . OriginalHeight; end ; function TScaledLayoutHelper . LocalToAbsoluteScaled( const Point: TPointF): TPointF; begin Result . X := Point . X / Self . Width / Self . OriginalWidth - Self . Position . X; Result . Y := Point . Y / Self . Height / Self . OriginalHeight - Self . Position . Y; end ; |
If you look at the original implementations of AbsoluteToLocal and LocalToAbsoluteyou will see they have different execution paths and calculations based on private members, so there may be some circumstances where my new ones don’t work as expected. They did work in my tests, and I am open to feedback.
http://delphi.org/2015/12/skill-sprint-using-firemonkey-layouts/
Using FireMonkey Layouts的更多相关文章
- 改变 TMemo 的背景颜色 (Firemonkey)
说明:展示使用程序码改变 Firemonkey TMemo 的背景颜色. 适用:XE6 源码下载:[原創]Memo改背景色_XE6.zip //---------------------------- ...
- Delphi XE2 之 FireMonkey 入门(45Finally) - 结题与问题
Delphi XE2 之 FireMonkey 入门(45Finally) - 结题与问题 很喜欢 FMX 的一些新控件, 如: TExpander.TArcDial.TComboTrackBar.T ...
- Delphi XE2 之 FireMonkey 入门(44) - 控件基础: TTreeView、TTreeViewItem
Delphi XE2 之 FireMonkey 入门(44) - 控件基础: TTreeView.TTreeViewItem TScrollBox -> TCustomTreeView -> ...
- Delphi XE2 之 FireMonkey 入门(39) - 控件基础: TScrollBox、TVertScrollBox、TFramedScrollBox、TFramedVertScrollBox
Delphi XE2 之 FireMonkey 入门(39) - 控件基础: TScrollBox.TVertScrollBox.TFramedScrollBox.TFramedVertScrollB ...
- Delphi XE2 之 FireMonkey 入门(33) - 控件基础: TFmxObject: SaveToStream、LoadFromStream、SaveToBinStream、LoadFromBinStream
Delphi XE2 之 FireMonkey 入门(33) - 控件基础: TFmxObject: SaveToStream.LoadFromStream.SaveToBinStream.LoadF ...
- Delphi XE2 之 FireMonkey 入门(30) - 数据绑定: TBindingsList: TBindExpression 的 OnAssigningValue 事件
Delphi XE2 之 FireMonkey 入门(30) - 数据绑定: TBindingsList: TBindExpression 的 OnAssigningValue 事件 表达式中的函数有 ...
- Delphi XE2 之 FireMonkey 入门(28) - 数据绑定: TBindingsList: 表达式函数测试: SelectedText()、CheckedState()
Delphi XE2 之 FireMonkey 入门(28) - 数据绑定: TBindingsList: 表达式函数测试: SelectedText().CheckedState() 示例构想: 用 ...
- Delphi XE2 之 FireMonkey 入门(27) - 数据绑定: TBindingsList: TBindScope
Delphi XE2 之 FireMonkey 入门(27) - 数据绑定: TBindingsList: TBindScope 如果在编写表达式时, 如果能够随意指认需要的控件就好了(通过 Owne ...
- Delphi XE2 之 FireMonkey 入门(1)
Delphi XE2 的 FireMonkey 是跨平台的, 暂时只准备看看它在 Windows 下(我是 32 位 Win7)的应用情况. 很新的东西, 相信有了它, 以后的界面将会更灵活.漂亮, ...
随机推荐
- 关于H5+css3的一些简单知识
最近在一个群里看到,有人在探讨H5,也看到自己关注的大神使用过H5的画布(canvas),于是心血来潮,看了点教程,也算对的起自己吧. 一.H5的新特性: 1.用于绘画的canvas元素 2.用于媒介 ...
- 项目开发中常用到的SQL语句
阅读目录 循环示例 循环示例 循环示例 循环示例 1.循环示例 在前端面试中最常见的问题就是页面优化和缓存(貌似也是页面优化),被问了几次后心虚的不行,平然平时多少会用到一些,但突然问我,很难把自己知 ...
- [转]第一章 Windows Shell是什么 【来源:http://blog.csdn.net/wangqiulin123456/article/details/7987862】
一个操作系统外壳的不错的定义是它是一个系统提供的用户界面,它允许用户执行公共的任务,如访问文件系统,导出执行程序,改变系统设置等.MS-DOS有一个Command.COM扮演着这个角色.然而Windo ...
- Git版本管理:Windows下Git配置与使用指南 Gitlab
简要介绍:Git是一个开源的分布式版本控制系统,用以有效.高速的处理从很小到非常大的项目版本管理. 一.安装 软件:msysGit-fullinstall-1.8.1.2 打开之后设置安装路径,默认为 ...
- ###Linux基础 - 2
点击查看Evernote原文. #@author: gr #@date: 2014-10-13 #@email: forgerui@gmail.com 一.Linux基础命令2 mount: 挂载U盘 ...
- 十分钟搭建个人网站:Jekyll主题BoHu
最近花了三天时间制作了我的第一个jekyll theme--BoHu.一款知乎风格的模板,使用jekyll模板引擎,十分钟就能搭建属于你自己的静态博客网站. 本主题的特征为: 知乎风格 分页导航使用的 ...
- 【转】SQL删除重复数据方法
例如: id name value 1 a pp 2 a ...
- javascripct字符串
String 对象 String 对象用于处理文本(字符串). 创建 String 对象的语法: new String(s); String(s); 参数 参数 s 是要存储在 String 对象中或 ...
- java异常处理机制 (转载)
java异常处理机制 本文来自:曹胜欢博客专栏.转载请注明出处:http://blog.csdn.net/csh624366188 异常处理是程序设计中一个非常重要的方面,也是程序设计的一大难点,从C ...
- js电话号码正则校验--座机和手机号
1.最新的电话号码段: 移动:134(1349除外)135 136 137 138 139 147 150 151 152 157 158 159 182 183 184 187 188 联通: 13 ...