• Emailx45:如何在Android/iOS设备上更改StatusBar颜色?


    How to changes the StatusBar color in Android / iOS devices? 作者:Emailx45

    NOTE: test in your device for effective usable, because in older Android system needs always tests!

    To remedy the incessant madness of some "programmers on call", let's change the color of the app's status bar on Android.

    Of course, here, we won't be resetting the color in the OS. Only, it will be changed on our app screen when it is in use.

    Finally, remembering that it is not necessary to re-invent the wheel, as it is already ready for our use. Of course, if you're an "excellent" blacksmith, you can do what you want with "your handfuls of raw iron."

    With just one or two lines of code, you can send the command to perform your task.

    First, we must identify the "units" where the referred command(s) are defined in RAD Studio (Delphi).


    Tested in:
    -- Motorola G8 - FullHD
    -- Android 11 64bits

    the units needed could be these:

    Delphi:
    uses
      Androidapi.Jni.App {GetJActivity} ,
      Androidapi.Jni.GraphicsContentViewText {JWindow} ,
      Androidapi.Jni.JavaTypes {JStringToString()} ,
      Androidapi.Helpers {TAndroidHelper};
    
    var
      MyJWindow: JWindow;
    
    Now, we must run the following command line:
    
    procedure TViewFormMain.Button2Click(Sender: TObject);
    begin
      MyJWindow  := TAndroidHelper.Activity.getWindow; // interfaced...
      //
      // if "value > integer" = Access Violation = Range check error = out of range values
      MyJWindow.SetStatusBarColor(  integer(  YourColorDesired    )   );
      // MyJWindow.SetStatusBarColor( integer( ColorPanel1.Color ) );
      //
      //  if you want dont use any variable, like above, try this:
      //  TAndroidHelper.Activity.getWindow.SetStatusBarColor(integer(ColorPanel1.Color));
      // in iOS you can use:
      // SetStatusBarBackgroundColor(aColor);
    end;

    That's it! Although, you will find many other ways to do it, because operating systems have evolved over time, as well as programming languages.

    Before, to forge a sword, it was necessary to harvest the "iron" at the source!
    Today, you can buy it on "Amazon" or "Alibaba"

    good luck!

    NOTE: if you used the "NULL" color, then, the colors dont will changes anymore!

    You need a "explicity" set a new color, like:
       MyJWindow.SetStatusBarColor( integer( ColorPanel1.ColorXXXXXXX ) );

    原文地址:http://bbs.2ccc.com/topic.asp?topicid=628457 

  • 相关阅读:
    list转datatable,SqlBulkCopy将DataTable中的数据批量插入数据库
    Html.BeginForm 与Section、Partial View 和 Child Action
    e.stopPropagation();与 e.preventDefault();
    NPOI导出
    Excel导入导出(篇二)
    Excel导入导出,通过datatable转存(篇一)
    ajax请求加载Loading或错误提示
    jQuery UI dialog
    Zebra_Dialog 弹出层插件
    Google浏览器导出书签
  • 原文地址:https://www.cnblogs.com/kinglandsoft/p/16177350.html
Copyright © 2020-2023  润新知