1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

Android Question StatusBar Color.

Discussion in 'Android Questions' started by Eme Fibonacci, Apr 9, 2016.

  1. Eme Fibonacci

    Eme Fibonacci Well-Known Member Licensed User

    Easy way to change the color of StaturBar?

    Maybe java in line?

    how use this in b4a?

    Code:
    public abstract void setStatusBarColor (int color)
    Thank you.
     
  2. somed3v3loper

    somed3v3loper Well-Known Member Licensed User

    This code is almost like this

    Code:
    Public Sub setStatusBarColor (color As Int)
    it does nothing by itself .
    If you find a library or java code that does change statusbar color we will try to help you convert it to B4A
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    Here:
    Code:
    Sub SetStatusBarColor(clr As Int)
       
    Dim p As Phone
       
    If p.SdkVersion >= 21 Then
         
    Dim jo As JavaObject
         jo.InitializeContext
         
    Dim window As JavaObject = jo.RunMethodJO("getWindow"Null)
         window.RunMethod(
    "addFlags"Array (0x80000000))
         window.RunMethod(
    "clearFlags"Array (0x04000000))
         window.RunMethod(
    "setStatusBarColor"Array(clr))
       
    End If
    End Sub
     
  4. Eme Fibonacci

    Eme Fibonacci Well-Known Member Licensed User


    Perfect!!

    And it works with " Theme.Holo " too!

    Thank you.
     
  5. Douglas Farias

    Douglas Farias Expert Licensed User

    hi erel.
    sory to ask here on a old topic.
    i m trying this code now here, and i have a question.

    how can i make to this code works 2 times on the same activity?
    i have a splash yellow, i want show the splash in yellow and statusbar too, later the splash visible = false i want change the color of statusbar again.
    i m trying but it stay with yellow, dont change the color on the second time.
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    I have tested it with:
    Code:
    Sub Activity_Click
       SetStatusBarColor(
    Rnd(0xFF0000000))
    End Sub
    It changes the color every time.
     
    Douglas Farias 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