Anyone know how to get this routine? I can get to FMX.Platform.iFMXScreenService, but no further.
Example code:
uses
FMX.Platform;
...
var
LService: IFMXScreenService;
begin
if TPlatformServices.Current.SupportsPlatformService(IFMXScreenService, LService) then
// Do something with LService
end;
Thanks - that went well.
Now is there any way to find out the height of the menu bar at the bottom of the screen please?
function GetResourceHeight(const AResourceName: string): Single;
var
LID: Integer;
LResources: JResources;
begin
Result := 0;
LResources := TAndroidHelper.Context.getResources;
LID := LResources.getIdentifier(StringToJString(AResourceName), StringToJString('dimen'), StringToJString('android'));
if LID > 0 then
Result := LResources.getDimensionPixelSize(LID) / TAndroidHelper.DisplayMetrics.density;
end;
function GetNavigationBarOffset: Single;
begin
Result := GetResourceHeight(‘navigation_bar_height’)
end;
function GetStatusBarOffset: Single;
begin
Result := GetResourceHeight(‘status_bar_height’);
end;
Thanks. Are there any restrictiions - will this work in android 10 as well as later ones please?
Which is the status bar (is this the top one?), and which is the navigation bar (is this the bottom one)?
Status is the top swipe down one. Navigation is the swipe up section with the 3 navigation buttons.
More info here: https://developer.android.com/develop/ui/views/layout/edge-to-edge
Thanks, David. Would have been nice if they had put in a Form.Include/Exclude Bars! The amount of work this has given me rewriting every damned Form.ReSize is huge!
That wouldn’t really make any sense. The bars - I assume you mean the navigation menu bars - are dependent on the operating system. They also depend on the user’s customization too, which is especially relevant in Android, macOS, and Linux where you can do some really freaky customizations including circular navigation bars.
By calling that function you’re asking the operating system for something specific to that OS flavor. It then stops being cross-platform compatible since you’d need different code for iOS et al. Yes, we could probably provide a function to do that with conditional code for every eventuality but also it would make more sense that the app should not really be in charge of working that sort of thing out - it should be either full screen, or not full screen.
Thanks, Ian. You are welcome to have a look at my offering from today - the essay on writing to android images! I will get continue to programme arount it, but I am reckoning on a month’s work.
Dodging the bars in IOS must be a terrible headache! You would have to know where to put your buttons and things so they don’t conflict, and that too sounds like an Herculean task.
Weren’t computers supposed to make life easier? Sigh.