Android Question How to call "setStatusBarColor" with Reflection

Discussion in 'Android Questions' started by cb56, Feb 26, 2015.

Similar threads

B4A Question StatusBar Color.
B4A Code Snippet Theme Colors
B4A Example AppCompat with ToolBar - minimal example
B4A Question [SOLVED] Change StatusBar icon color
B4A Code Snippet Set Status bar colors
  1. cb56

    cb56 Member Licensed User

    Last edited: Feb 26, 2015
    KZero likes this.
  2. Erel

    Erel Administrator Staff Member Licensed User

    This code calls this API:
    Code:
    Dim jo As JavaObject
    jo.InitializeContext
    jo.RunMethodJO(
    "getWindow"Null).RunMethod("setStatusBarColor"Array(Colors.Red))
    It didn't do anything when I test it.
     
    Alexander Stolte and amir lotfi like this.
  3. DonManfred

    DonManfred Expert Licensed User

    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
    Code:
    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
    Code:
    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
    Code:
    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...
     
  4. cb56

    cb56 Member Licensed User

    It works with Material Theme.

    Thanks
     
    Nea likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice