【发布时间】:2018-06-30 19:47:37
【问题描述】:
我在VertScrollBox1 上有GridLayout1。垂直滚动框滚动显示网格布局的内容。我需要检测垂直滚动框何时到达底部,以便将更多内容加载到网格布局中。
每当再次到达底部时再做一次。
我怎样才能做到这一点?
【问题讨论】:
标签: android ios delphi firemonkey delphi-10.2-tokyo
我在VertScrollBox1 上有GridLayout1。垂直滚动框滚动显示网格布局的内容。我需要检测垂直滚动框何时到达底部,以便将更多内容加载到网格布局中。
每当再次到达底部时再做一次。
我怎样才能做到这一点?
【问题讨论】:
标签: android ios delphi firemonkey delphi-10.2-tokyo
使用VertScrollBox1 的OnViewportPositionChange()。然后一些简单的算术告诉你什么时候处于底部:
uses Math, ...;
// ...
procedure TForm1.VertScrollBox1ViewportPositionChange(Sender: TObject;
const OldViewportPosition, NewViewportPosition: TPointF;
const ContentSizeChanged: Boolean);
begin
if CompareValue(NewViewportPosition.Y, GridLayout1.Height - VertScrollBox1.Height) = EqualsValue then
Memo1.Lines.Add('At bottom, time to grow and load more content to the GridLayout');
end;
由于我们比较的值是浮点数,所以使用Math.CompareValue() 进行比较。
或者function SameValue(),也在Math单元中
【讨论】: