大佬教程收集整理的这篇文章主要介绍了delphi – 为FireMonkey中的ListBox添加字符串动画,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
procedure TForm6.AddItem(s: String); var l : TListBoxItem; OldHeight : Single; begin l := TListBoxItem.Create(Self); l.Text := s; OldHeight := l.Height; l.Height := 0; l.Parent := ListBox1; l.opacity := 0; l.AnimateFloat('height',OldHeight,0.5); l.AnimateFloat('Opacity',1,0.5); end;
该项扩展并淡入.但是我希望能够将字符串添加到ListBox中的任意位置 – 实际上是在当前的ItemIndex中.
有谁知道如何做到这一点?
procedure TForm1.AddItem(s: String); var l : TListBoxItem; OldHeight : Single; I: Integer; index : Integer; begin l := TListBoxItem.Create(nil); l.Text := s; OldHeight := l.Height; l.Height := 0; l.opacity := 0; l.Index := 0; l.Parent := ListBox1; Index := Max(0,ListBox1.ItemIndeX); for I := ListBox1.Count - 1 downto Index + 1 do begin ListBox1.Exchange(ListBox1.ItemByIndex(i),ListBox1.ItemByIndex(i-1)); end; ListBox1.ItemIndex := Index; l.AnimateFloat('height',0.5); end;
但有点荒谬.如果没有选择项目,它(最终)将字符串添加到位置0,否则在所选项目之前添加它.这个解决方案让我想起Bubble Sort.你需要将数学单元添加到uses子句中以使max函数起作用.
这确实似乎是FireMonkey中的一个错误(检查Quality Central #102122),但我怀疑未来的FireMonkey更新将解决这个问题.如果有人能看到更好的方式来做到这一点….
对于那些感兴趣的人,我也是made a movie关于这一点,这更清楚地说明了事情.
以上是大佬教程为你收集整理的delphi – 为FireMonkey中的ListBox添加字符串动画全部内容,希望文章能够帮你解决delphi – 为FireMonkey中的ListBox添加字符串动画所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。