为什么控件无法跨越Android FireMonkey应用程序中的多个列或行? [英] Why won't controls span multiple columns or rows in an Android FireMonkey app?
问题描述
我有一个带有GridPanelLayout且与客户端对齐的FireMonkey应用程序。它有6列和16行。控件包括字形,编辑和按钮。 TEdit跨越多列,而TButton跨越多列和行。这些控件当前都与客户端对齐。
I have a FireMonkey app with a GridPanelLayout, aligned to client. It's got 6 columns and 16 rows. Controls include glyphs, edits, and buttons. The TEdits span multiple columns, and the TButtons span both multiple columns and rows. The controls are currently all aligned to client.
当我在Windows上编译和运行时,所有内容和行为均符合预期。但是,在Android设备(我尝试过两种,Android 6.0.1和Amazon FireOS)上,所有控件都不能跨越一个以上的列或行。它们每个只有一个牢房。而不是跨越6列,TEdits仅跨越1列。而不是跨越2列和2行,TButton也跨越1列和1行。
When I compile and run on Windows everything looks and acts as expected. However, on Android devices (I tried two, Android 6.0.1, and Amazon FireOS) none of the controls span more than one column or row. They're each just one cell big. Instead of spanning 6 cols, TEdits span just 1 col; instead of spanning 2 cols and 2 rows, TButtons also span 1 col and 1 row.
为什么控件在Android上不能跨越多列或多行?
Why won't the controls span multiple columns or rows on Android?
推荐答案
VCL和FireMonkey都无法存储<$ c $的 ControlCollection
c> TGridPanel / TGridPanelLayout
正确地将框架/窗体子类化或将框架放置在另一个框架/窗体上。
Both VCL and FireMonkey fail to store the ControlCollection
of a TGridPanel
/ TGridPanelLayout
correctly when a frame/form gets subclassed or a frame placed on another frame/form.
此错误同时适用于VCL和FMX。早在2011年就已向旧的质量控制部门报告了该报告,但从未得到修复(例如:#92298 ,#123225 )。
This bug applies to both VCL and FMX. It has been reported to the old QC as early as 2011 but never been fixed (examples: #92298, #123225).
示例:在 TGridPanelLayout
中放置 TButton
它放在 TFrame
:
Example: Drop a TGridPanelLayout
with a TButton
in it on a TFrame
:
object GridPanelLayout1: TGridPanelLayout
(...)
ControlCollection = <
item
Column = 0
ColumnSpan = 2
Control = Button1
Row = 0
RowSpan = 2
end>
object Button1: TButton
Align = Client
Size.Width = 421.000000000000000000
Size.Height = 257.000000000000000000
Size.PlatformDefault = False
TabOrder = 0
Text = 'Button1'
end
end
以后如果将子类作为框架的子类,则IDE会为其从基类继承的组件存储大量冗余属性。通常在第一次按F9键后, ColumnSpan
和 RowSpan
属性会被无故删除。在子类上,它看起来像这样:
When you later subclass the frame, the IDE tends to store a lot of redundant properties for the components it inherited from the base class. Usually after the first press of F9, the ColumnSpan
and RowSpan
properties get removed for no reason. On the subclass, it then looks something like this:
inherited GridPanelLayout1: TGridPanelLayout
(...)
ControlCollection = <
item
Column = 0
Control = Button1
Row = 0
end>
inherited Button1: TButton
Size.Width = 210.500000000000000000
Size.Height = 128.500000000000000000
end
end
请注意Size属性如何更改。此外, ControlCollection
项得到重新定义,而 ColumnSpan
和 RowSpan
属性完全丢失。这是原因。
Note how the Size property has changed. Also, the ControlCollection
items get re-defined, yet the ColumnSpan
and RowSpan
properties are missing completely. This is the cause.
此错误适用于您,因为在FMX中,针对特定平台的专用视图被实现为 主视图 。
This bug applies to you because in FMX, specialized views for specific platforms are implemented as subclasses of the master view.
版本控制该系统有助于检测冗余属性何时潜入DFM文件中。在上面的示例中,当子类未对其进行更改时,完全删除继承的GridPanelLayout1
块是合法的。此外,我建议您在不打开窗体设计器窗口的情况下构建项目,因为它经常会损坏您的DFM文件,并在每次机会时都重新添加冗余属性。
A version control system helps detecting when redundant properties sneak into DFM files. In the above example, it is legal to completely remove the inherited GridPanelLayout1
block when your subclass does not change it. Moreover, I advise you to build your project with no form designer window open as it often will corrupt your DFM file and re-add the redundant properties at every opportunity.
这篇关于为什么控件无法跨越Android FireMonkey应用程序中的多个列或行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!