Android Question Change the Navigation Bar Color with Transparent Status Bar

Keith Yong

Active Member
Licensed 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

Keith Yong

Active 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).
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

Erel

Administrator
Staff member
Licensed 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
 
Top