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

只愿长相守 提交于 2019-12-12 07:16:39

问题


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:


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.



来源:https://stackoverflow.com/questions/27664134/why-are-all-the-dialogs-are-using-the-old-android-2-x-style

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!