Android Question Change the Navigation Bar Color with Transparent Status Bar

Keith Yong

Active Member
Licensed User
Longtime User
Not sure that I understand. Can you post a screenshot and an image with the desired colors?
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

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

Attachments

  • WhatsApp Image 2019-06-26 at 9.42.26 AM.jpeg
    WhatsApp Image 2019-06-26 at 9.42.26 AM.jpeg
    8.4 KB · Views: 843
Upvote 0

Keith Yong

Active Member
Licensed User
Longtime 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).

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?
 

Attachments

  • unnamed-2.jpg
    unnamed-2.jpg
    42.2 KB · Views: 475
  • unnamed.jpg
    unnamed.jpg
    40.2 KB · Views: 480
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
This is the best I got:
B4X:
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(0x00000200, 0x08000000)))
       Activity.Height = Activity.Height + 80dip   
       Dim pnl As Panel
       pnl.Initialize("")
       pnl.Color = Colors.Red
       Activity.AddView(pnl, 0, Activity.Height + 24dip, 100%x, 80dip)
   End If
   Activity.LoadLayout("1")
End Sub
 
Upvote 0
Top