Search code examples
delphifiremonkeylistviewitemmarginsdelphi-10-seattle

Firemonkey TListView - Adjust item text margins


I'm implementing a TListView in a Firemonkey app, where the height of each list item must be as small as possible, just large enough to fit the text. However, there is an apparent margin on the top of the text, leaving an empty space at the beginning of each list item.

The item appearance is set to ListItemRightDetail, but I cannot find any properties anywhere to allow me to control this - neither in the FMX design or the Styles for the List View.

How do I eliminate the margin at the top of list item text so that I can minimize the list item heights?


Solution

  • There are not necessarily any "margin" properties, as this margin is pretty much built-in. However, this can be adjusted by modifying the PlaceOffset.Y property, and making them a negative value. This will "lift up" the contents within each list item. I find -3 to be a sufficient amount to reduce this margin...

    ListView1.ItemAppearanceObjects.ItemObjects.Text.PlaceOffset.Y := -3;
    ListView1.ItemAppearanceObjects.ItemObjects.Detail.PlaceOffset.Y := -3;