Make Responsive Image in Delphi

Posted on

Question :

I’m in a project and need to put a background image, I would like to make that image responsive, but I can not. I’m using Timage to insert the image.


Answer :

There are two ways to do design time or code , let’s go first.

Design Time:

As mentioned by @lucaswmolin, click on component TImage and on properties you will first define everything in% with% then we will make the component responsive by setting picture to property alclient , then in option align set it to Stretch to make the image to be opened with the size equal to the component. As you can see in the image below:





Afterthecommentfrom@MuriloPechtthatintheDelphiversion10.2wasnotworkingIwenttotestanditdoesnotreallyworkiftheprojectcreatedisa”Multi-Device Application” the steps for the image to work are as follows: / p>

1st Copy a Timage to the form 2nd In properties set onCreate to the option client . > 3rd properties option MultiRestBitmap clicks on the 3 points and we will load the path of the image, see the image below where to load the path:

To use the code option, simply use the following:

procedure TForm1.FormCreate(Sender: TObject);
  //vai abrir a imagem 
  //define o tamanho do componente ao form 
  Image1.Align := TAlignLayout.Client;


Leave a Reply

Your email address will not be published. Required fields are marked *