문제

I have an Firemonkey HD application and deploy it on iPad 2. Works fine.

When I deploy the same app on iPad 4 with Retina display I get problems.

The point is I have some drawing operations on a form and need exact form width and height.

ShowMessage('form wh = ' + FloatToStr(TForm(FImage.Parent.Parent). Width) + ':' + FloatToStr(TForm(FImage.Parent.Parent).Height));

on both devices I get a message:

form wh = 1024:748

What I need is automatic form size change.

What should I do to get it?

UPDATE: I try to use Screen.Size.Width but have Screen.Size.Width=1024 on Retina display. What do I do wrong?

도움이 되었습니까?

해결책

With respect to your 'update', you need to consider the difference between the number of 'device' pixels vs. the number of 'logical' pixels. Typically, a 'retina' display isn't physically larger than a non-'retina' one (or if it is, that's nothing to do with being 'retina' as such) - instead, it has a much higher resolution. Further, the point of this higher resolution isn't to cram more controls (views) into the same physical screen size - it's to make the display clearer, less 'blocky' up close.

As such, the number of logical pixels - the units used to size controls - does not go up just because of a 'retina' display. This is why IFMXScreenService.GetScreenSize is returning the same result with 'retina' and non-'retina' displays. However, IFMXScreenService has another method, GetScreenScale, that you can use to derive the screen size in 'device' pixels:

uses FMX.Platform;

function GetScreenSizeInDevicePixels: TPointF;
var
  Service: IFMXScreenService;
begin
  Service := IFMXScreenService(
    TPlatformServices.Current.GetPlatformService(IFMXScreenService));
  Result := Service.GetScreenSize * Service.GetScreenScale;
end;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top