Jump to content
Antony Augustus

Rounded corners in Firemonkey TListView Item

Recommended Posts

Is it possible to have rounded corners in Firemonkey TListView Item? Have anybody tried it. I tried steps like

1) Edit the Custom style of TListView and replace the 'itembackground' style with a TRectangle

2) Edit the Custom style of TListView and replace the 'itembackground' style with a TLayout and TRectangle

 

But nothing worked. Any suggestions how to achieve the rounded corners for a TListView Item?

Share this post


Link to post

One solution is to use DynamicAppearance and add an image.

I explained this (in french) here and there
The only job to add is to rework the bitmap to have RoundedCorners in this part

procedure TForm1.ListView1UpdatingObjects(const Sender: TObject;
  const AItem: TListViewItem; var AHandled: Boolean);
var AListItemBitmap : TListItemImage;
    AListItemText : TListItemText;
    AColor : TAlphaColor;
begin
AListItemBitmap:=AItem.Objects.FindObjectT<TListItemImage>('Image2');
AListItemText:=AItem.Objects.FindObjectT<TListItemText>('Text1');

if assigned(AListItemBitmap) then
 begin
    AListItemBitmap.Bitmap:=TBitmap.Create(40,40);
    try
       AColor:=StringToAlphaColor(AListItemText.Text)
    except 
      AColor:=TAlphaColorRec.Null;
    end;
    AListItemBitmap.Bitmap.Clear(AColor);
 end;
end;

image.thumb.png.5119ade116fafe397ab775600f601ddc.png

 

Still some work to do but a first result

 

Edited by Serge_G

Share this post


Link to post

Thank you very much Serge. It looks like TListView by default does not support rounded corners for its ListItem. I am going to use a TFrame, TLayout and a TRect to achieve the same effect.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×