Android Question How to apply gradient to status bar?

Status
Not open for further replies.

Erel

Administrator
Staff member
Licensed User
The solution in that post causes the standard action bar to be hidden. You need to recreate it yourself.



Example of a an activity that is extended into the status bar. Note that only the Android 5+ layout was tested.

New B4XPages example:
 

Attachments

  • 8.9 KB Views: 491
Last edited:

jtare

Active Member
Licensed User
Thank you for the example project.
I'm using appcompat with no actionbar, I use a toolbar as actionbar (added in the designerview), I had to move 20dip down the toolbar and content panel, then set the same gradient color for the activity background and for the toolbar and seems to work just fine.
 

jtare

Active Member
Licensed User
Status bar height seems to be 25dip, not 20dip. Is this correct? Or depends on the screen?
 

jtare

Active Member
Licensed User
For some reason, now when I tried to input text on a edittext the keyboard covers the view, before it moved up to always make it visible. I tried to add this to the manifest editor but nothing happened, the view gets covered by the keyboard.
B4X:
SetActivityAttribute(Main,  android:windowSoftInputMode, "stateHidden|adjustPan")
I assume this is related with the modifications done to the status bar
 
Last edited:

Erel

Administrator
Staff member
Licensed User

moinamh

Member
The solution in that post causes the standard action bar to be hidden. You need to recreate it yourself.



Example of an activity that is extended into the status bar. Note that only the Android 5+ layout was tested.
I tried using this code in B4XPages:
B4X:
    Dim ph As Phone
    If ph.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)))
        Root.Height = Root.Height +80dip
    End If
        Dim pnl As Panel
        pnl.Initialize("")
        pnl.Color = Colors.Transparent
        Root.AddView(pnl, 0, Root.Height + 24dip, 100%x, 80dip)
The statusbar got transparented but the bottom of the page shown as a white space. like this image (Yeap , thats NavigationBar) :
B4a_SS.PNG

That Code works fine for normal activity , but I got no idea how to solve the problem in B4X Page.
 
Status
Not open for further replies.
Top