On our previous post I talk about using Bluestacks as an emulator (AVD). One problem we can face when deploying for Intel based devices is a misalignment that can occurs on status bar. This issue can be observed on Bluestacks too, as you can see (that black strip is actually the status bar).
After asking for help on I received a nice solution from Hsu Neptune, a member from the great community Delphi iOS & Android Developers at Google Plus, managed by Lars Fosdal.
Hsu Neptune pointed the solution, but he was kind enough to explain in plain english 🙂
Well, there he advices that this fix should be used on Delphi XE8 (not C++ Builder – for that see the original post, bellow). I was able to ask for a test on Delphi Seattle (that also carries the same problem) and it works there. He is the fix:
1. Copy FMX.Platform.Android.pas to your project’s folder and Add to the project.
2. Open FMX.Platform.Android.pas and search for ” function TWindowManager.RetrieveContentRect: TRect; ”
3. Modify the code:
function TWindowManager.RetrieveContentRect: TRect; var Activity: JActivity; NativeWin: JWindow; DecorView: JView; ContentRectVisible, ContentRect: JRect; begin Activity := SharedActivity; if Activity <> nil then begin NativeWin := Activity.getWindow; if NativeWin <> nil then begin FStatusBarHeight := FNewContentRect.top; ContentRect := TJRect.Create; DecorView := NativeWin.getDecorView; DecorView.getDrawingRect(ContentRect); // Fix by Flying Wang & CallInUIThread( procedure begin if (not PlatformAndroid.GetFullScreen(nil)) and (SharedActivity.getWindow.getAttributes.flags and TJWindowManager_LayoutParams.JavaClass.FLAG_FULLSCREEN <> TJWindowManager_LayoutParams.JavaClass.FLAG_FULLSCREEN) then begin // http://www.2cto.com/kf/201307/227536.html ContentRectVisible := TJRect.Create; DecorView.getWindowVisibleDisplayFrame(ContentRectVisible); if (ContentRect.top < 1) or (ContentRectVisible.top < FStatusBarHeight) then begin ContentRect.top := ContentRectVisible.top; FNewContentRect.top := ContentRectVisible.top; FStatusBarHeight := FNewContentRect.top; end; end; end); Result := TRect.Create(Round(FNewContentRect.left / FScale), Round(FNewContentRect.top / FScale), Round(ContentRect.right / FScale), Round(ContentRect.bottom / FScale)); end; end; end;
4. Re-compile the project and deploy
Now you will get this:
To read the original post click here