Android Question How to call "setStatusBarColor" with Reflection

DonManfred

Expert
Licensed User
It didn't do anything when I test it.
The flow is more than just that.
first it get getIdentifier("config_enableTranslucentDecor", "bool"
then it
get the bool to know whether the statusbar and navbar are translucent
B4X:
                int[] attrs = {android.R.attr.windowTranslucentStatus, android.R.attr.windowTranslucentNavigation};
                app.Log("?X3?");
                TypedArray a = app.context.obtainStyledAttributes(attrs);
                app.Log("?X4?"+a);
                try{
                    mStatusBarAvailable = a.getBoolean(0, false);
                    mNavBarAvailable = a.getBoolean(1, false);
                } finally {
                    a.recycle();
                }
and
B4X:
                WindowManager.LayoutParams winParams = win.getAttributes();
                // check window flags
                int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
                if ((winParams.flags & bits) != 0) {
                    mStatusBarAvailable = true;
                }
                bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
                if ((winParams.flags & bits) != 0) {
                    mNavBarAvailable = true;
                }
and in last step it adds a view to the viewgroup
B4X:
  private void setupStatusBarView(Context context, ViewGroup decorViewGroup) {
      mStatusBarTintView = new View(context);
      LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, mConfig.getStatusBarHeight());
      params.gravity = Gravity.TOP;
      if (mNavBarAvailable && !mConfig.isNavigationAtBottom()) {
          params.rightMargin = mConfig.getNavigationBarWidth();
      }
      mStatusBarTintView.setLayoutParams(params);
      mStatusBarTintView.setBackgroundColor(DEFAULT_TINT_COLOR);
      mStatusBarTintView.setVisibility(View.GONE);
      decorViewGroup.addView(mStatusBarTintView);
  }
All this are NOT WORKING code-snippets from a librarywrapper whih does not work... I always stuck in the last point....

But yesterday i got the MaskedImageView running... Maybe it helps here too what i did to get it work yesterday. The issue is similar...
 

cb56

Member
Licensed User
This code calls this API:
B4X:
Dim jo As JavaObject
jo.InitializeContext
jo.RunMethodJO("getWindow", Null).RunMethod("setStatusBarColor", Array(Colors.Red))
It didn't do anything when I test it.
It works with Material Theme.

Thanks
 
  • Like
Reactions: Nea
Top