Android Question Change the Navigation Bar Color with Transparent Status Bar

Discussion in 'Android Questions' started by Keith Yong, Jun 25, 2019.

  1. Keith Yong

    Keith Yong Active Member Licensed User

  2. Erel

    Erel Administrator Staff Member Licensed User

    Not sure that I understand. Can you post a screenshot and an image with the desired colors?
     
  3. Keith Yong

    Keith Yong Active Member Licensed User

    Hi Erel,

    As you can see the image uploaded, I would like to change the navigation bar colour and status bar transparent. The following code doesn't work to change navigation bar colour

    Code:
    Dim jo As JavaObject
            jo.InitializeContext
            
            
    Dim window As JavaObject = jo.RunMethod("getWindow"Null)
            window.RunMethod(
    "addFlags"Array(Bit.Or(0x000002000x08000000)))
            jo.RunMethodJO(
    "getWindow"Null).RunMethod("setNavigationBarColor"Array(Colors.RGB(28,49,58)))
     

    Attached Files:

  4. Erel

    Erel Administrator Staff Member Licensed User

  5. Keith Yong

    Keith Yong Active Member Licensed User

    if don't call addFlags, navigation bar can change colour but status bar does not transparent.

    if call addFlags, navigation bar cannot change colour, always show as black.
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    The activity view is probably too short so it looks black. I cannot test it right now but try to increase the activity height (in the code).
     
  7. Keith Yong

    Keith Yong Active Member Licensed User

    Hi Erel, As you can see the attachment images. One screen with bigger Height (unnamed) and another one is normal screen without navigation height(unnamed-2).

    I wish to change the navigation colour, instead of having semi transparent. May I know how can I achieve that?
     

    Attached Files:

  8. Erel

    Erel Administrator Staff Member Licensed User

    It would be easier if you upload a small project with the relevant code.
     
  9. Keith Yong

    Keith Yong Active Member Licensed User


    Hi Erel, I have uploaded the project.
     

    Attached Files:

  10. Erel

    Erel Administrator Staff Member Licensed User

    This is the best I got:
    Code:
    Sub Activity_Create(FirstTime As Boolean)
       
    Dim p As Phone
       
    If p.SdkVersion >= 4.4 Then
           
    Dim jo As JavaObject
           
    Dim window As JavaObject = jo.InitializeContext.RunMethod("getWindow"Null)
           window.RunMethod(
    "addFlags"Array(Bit.Or(0x000002000x08000000)))
           
    Activity.Height = Activity.Height + 80dip   
           
    Dim pnl As Panel
           pnl.Initialize(
    "")
           pnl.Color = 
    Colors.Red
           
    Activity.AddView(pnl, 0Activity.Height + 24dip100%x80dip)
       
    End If
       
    Activity.LoadLayout("1")
    End Sub
     
    Peter Simpson likes this.
  11. Keith Yong

    Keith Yong Active Member Licensed User

    Thanks Erel, I believe this best way to work on it.
     
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