Screen resolution & device profiles

I started doing an app for android in Delphi XE5, and encountered some troubles. First one was, when creating new profile for device in design time. I created new profile for my HTC One (M7), which has 4,7" screen at 1080x1920 resolution. When created profile with such data, I only got the top left part of picture after I ran it on the device itself. So, since then I'm running my app, so I can test at least the code I'm doing, in mode with default profile " 5,1" WVGA Android Phone (480dp x 800dp: mdpi) ", since at this settings, I see about 75% of the design-time form size... Anyone has any idea why this is happening, and if that's XE5's problem, or the app's itself when ran on the phone?

Update: I figured from the sample projects of RAD studio, that if I use Samsung Galaxy S4 template, which also has 1080x1920 resolution, it's the correct form for my HTC One as well. Just can't see it's settings, since stock profiles can't be edited, but surely isn't set as 1080x1920, because the form itself looks smaller than the one I created.

I know now I can use this settings, but just don't understand why the difference.

Anyway, the main question now is, how to set up the screen settings so that they apply and change in dependence of the device and device's screen resolution...?

Thanks.

UPDATE: Just got confirmed from a friend that on his Nexus tablet he sees the whole picture, meaning the form's size just as is set in delphi. http://en.wikipedia.org/wiki/Nexus_7_(2012_version)

Wtf?


This is a real problem for most mobile phones. Most devices have a screenscale. ios has it, most modern Android devices have it. What you have to do is to scale a bitmap to the screen by multiplying its dimensions by the screen scale. Example from my own code:

function TMandel_View.get_screenscale: Single;
var
   ScreenService: IFMXScreenService;
begin
   Result := 1;
   if TPlatformServices.Current.SupportsPlatformService (IFMXScreenService, IInterface(ScreenService)) then
   begin
      Result := ScreenService.GetScreenScale;
   end; // if
end; // get_screenscale //

procedure TMandel_View.FormActivate (Sender: TObject);
var
  screenscale: Single;
begin
   if not FActivated then  // Initialization should be called only once
   begin
      FActivated := True;  // Disable initialization each time form is activated
      screenscale := get_screenscale;
      FImageBitmapWidth := FImage.Width * screenscale;
      FImageBitmapHeight := FImage.Height * screenscale;
      FImage.Bitmap.SetSize (Round (FImageBitmapWidth), Round (FImageBitmapHeight));
// etc...
   end; // if
end; // FormActivate //

You might want to view the full sourcode but this is pretty much it.


To get everything to resize use this tutorial:

Resizable form elements


A hacky way would be to store your design time width and height as const then use them in an OnCreate event with the device's actual screen width and height like

Offset.Height := Design.Height - Screen.Height;
Offset.Width := Design.Width - Screen.Width;

You then use these offsets to align all your labels,edits,ect .

链接地址: http://www.djcxy.com/p/96696.html

上一篇: 适用于iOS应用程序的FireMonkey XE5图标

下一篇: 屏幕分辨率和设备配置文件