Why are all the dialogs are using the “old” Androi

2020-02-29 10:55发布

I am currently using RAD Studio XE7 and just wondering why all the dialogs in my Android app are using the "old" 2.x style? And how to force my Android app to use the 4.x style in all the dialogs like date picker and MessageDlg?

Using StyleBook and modying the AndroidManifest.xml didn't work. Thanks in advance.

1条回答
We Are One
2楼-- · 2020-02-29 11:15

David I posted the answer to your same question on the Embarcadero Community Answers site:

Why all the dialogs are using the "old" Android 2.x style?

I alerted our development team and they found the problem in an Android helper function. Here is the reply from R&D with the workaround:

The fix is very simple : In FMX.Helpers.Android it’s this function

function GetNativeTheme: Integer;
var
  LStyleDescriptor: TStyleDescription;
begin
  Result := 0;
  if not IsGingerbreadDevice and (Screen <> nil) and (Screen.ActiveForm <> nil) and (Screen.ActiveForm.StyleBook <> nil) then
  begin
    LStyleDescriptor := TStyleManager.FindStyleDescriptor(Screen.ActiveForm.StyleBook.Style);
    // GetThemeFromDescriptor(LStyleDescriptor);
    Result := GetThemeFromDescriptor(LStyleDescriptor); // <--here the result assignment was missing
  end;
end;

And here is an Embarcadero blog post explaining how to apply the fix:

How to get Android 4.4.x style for your XE7 dialog boxes

In the FMX.Helpers.Android.pas unit, you need to modify the GetNativeTheme function... You will find the original source code unit in the "C:\Program Files (x86)\Embarcadero\Studio\15.0\source\fmx" folder.  Copy the "FMX.Helpers.Android.pas" source file to your project and modify the line to set the return Result. Add the source file to your project in the IDE. Build your app and see the modern dialog boxes on your Android KitKat devices.

查看更多
登录 后发表回答