我应该使用什么控件来在Delphi Firemonkey中创建此UI [英] What control should I use to create this UI in Delphi Firemonkey

查看:196
本文介绍了我应该使用什么控件来在Delphi Firemonkey中创建此UI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我愿意创建这个UI:





我试过 TListBox ,但左右图不能设置。



我试过 TListView 但与 TListBox



相同的问题我试过 TGrid 自定义列,文本和图像的问题已解决,但我无法创建每行的标题(它没有像colspan)



我需要创建一个自定义控件并重复它。



什么是最佳解决方案?

任何解决方案或指南行将不胜感激。

解决方案



感谢@Mike Sutton回答,这是结果

解决方案

这里的样式与标准的TListBoxItem样式非常不同,从头开始可能是有意义的,在这种情况下,访问默认样式的问题变得不重要。 >


  • 将一个TStyleBook添加到您的表单中。
  • 将表单的StyleBook属性设置为指向它。 / li>
  • 双击该图标以打开编辑器。

  • 将TLayout拖放到结构面板并将其放在将存在的唯一项目上。 / li>
  • 设置TLayout的StyleName属性(例如,
  • 拖放其他组件以构建您想要的布局(记住TLayouts用于'隐藏'定位)。

  • 将子类TLIstBoxItem设置为TScoreListBoxItem(如果使用上面提到的StyleName)。

  • / li>
  • 为您的文本,图片等添加属性。
  • 在每个setter方法中,缓存数据并调用方法,例如: / li>


procedure SetFlag1;
var O:TFMXObject;
begin
O:= FindStyleResource('flag1'); //如果O是TImage然后
TImage(O).Bitmap.Assign(FFlag1); //该项目的样式名称
;
end;




  • 重写ApplyStyle方法并调用 em>


  • 现在在代码中创建您的项目:




Item:= TScoreListBoxItem.Create(Self);
ListBox1.AddObject(Item);
Item.Flag1.LoadFromReource ...
...


I am developing an application for mobile (android and ios) by Delphi xe5.

I am willing to create this UI:

I tried TListBox but image on left and right cant be set.

I tried TListView but same problem as TListBox

I tried TGrid with custom column, The problem of texts and images is solved but I can't create headers of each rows (it hasn't something like colspan)

What I need is to create a custom control and repeat it.

What is the best solution?

Any solution or guide line will be appreciated.

Solution

Thanks @Mike Sutton for answer, this is the result

解决方案

The style here is so different from a standard TListBoxItem style that is probably makes sense to start from scratch, in which case the issues with accessing the default styles become immaterial.

  • Add a TStyleBook to your form.
  • Set the StyleBook property of the form to point to it.
  • Double click the icon to open the editor.
  • Drag a TLayout to the structure panel and drop it on the only item which will be there.
  • Set the StyleName property of the TLayout (e.g. ScoreListBoxItemStyle).
  • Drag/drop other components to build up the layout you want (remember TLayouts for 'hidden' positioning).
  • Set the StyleName property of any components you want reference from your code.

  • Subclass TLIstBoxItem to TScoreListBoxItem (if using the StyleName suggested above).

  • Add properties for your text, images etc.
  • In the setter methods for each of these, cache the data and call a method such as:

procedure SetFlag1; var O: TFMXObject; begin O := FindStyleResource('flag1'); //StyleName of the item if O is TImage then TImage(O).Bitmap.Assign(FFlag1); end;

  • Override the ApplyStyle method and call all of your methods that set the data in the style.

  • Now create your items in code:

Item := TScoreListBoxItem.Create(Self); ListBox1.AddObject(Item); Item.Flag1.LoadFromReource ... ...

这篇关于我应该使用什么控件来在Delphi Firemonkey中创建此UI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆