Android Question Transparent Status Bar

Keith Yong

Active Member
Licensed User
B4X:
SetApplicationAttribute(android:theme, "@style/Custom")
CreateResource(values-v20, theme.xml,
<resources>
  <style
  name="Custom" parent="@android:style/Theme.Holo.Light.Panel">
     <item name="android:windowTranslucentNavigation">false</item>
     <item name="android:windowTranslucentStatus">true</item>
  </style>
</resources>
)

CreateResource(values-v19, theme.xml,
<resources>
  <style
  name="Custom" parent="@android:style/Theme.Holo.Light.Panel"> 
     <item name="android:windowTranslucentNavigation">false</item>
     <item name="android:windowTranslucentStatus">true</item>
  </style>
</resources>
)
Hi, I manage to put above code into manifest editor and it works for small device, the status bar show on top of the image. But when I run the same program into bigger device "Samsung Note 8", the screen doesn't cover into full. May I know what did I miss out.
 

Attachments

Keith Yong

Active Member
Licensed User
You are using the holo theme which is an old theme. You should use material theme on v21+.

Try this: https://www.b4x.com/android/forum/t...n-new-android-flagship-devices.77980/#content

B4X:
SetApplicationAttribute(android:theme, "@style/Custom")
CreateResource(values-v20, theme.xml,
<resources>
  <style
  name="Custom" parent="@android:style/Theme.Material.Light">
     <item name="android:windowTranslucentNavigation">false</item>
     <item name="android:windowTranslucentStatus">true</item>
  </style>
</resources>
)

CreateResource(values-v19, theme.xml,
<resources>
  <style
  name="Custom" parent="@android:style/Theme.Material.Light">
     <item name="android:windowTranslucentNavigation">false</item>
     <item name="android:windowTranslucentStatus">true</item>
  </style>
</resources>
)
With this code, I manage to show the screen in full and the status bar cover on top of the image. May I know how can I make the status bar fully transparent and just show the status bar icon only.
 

Attachments

Keith Yong

Active Member
Licensed User
B4X:
    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)))
        Activity.Height = Activity.Height + 25dip
        
        If ph.SdkVersion > 20 Then
            Dim jo As JavaObject
            jo.InitializeContext
            Dim window As JavaObject = jo.RunMethodJO("getWindow", Null)
            Dim view As JavaObject = window.RunMethodJO("getDecorView",Null)
        
            view.RunMethod("setSystemUiVisibility",Array(Bit.Or(0x00002000,view.RunMethod("getSystemUiVisibility",Null)))) 'Light style with black icons and text
        End If
    End If
I did not put anything in the manifest and just put the above code, it can achieve the thing that I want. May I know is the code working fine?
 

Keith Yong

Active Member
Licensed User
B4X:
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)))
        Activity.Height = Activity.Height + 25dip
        
        If ph.SdkVersion > 20 Then
            Dim jo As JavaObject
            jo.InitializeContext
            Dim window As JavaObject = jo.RunMethodJO("getWindow", Null)
            Dim view As JavaObject = window.RunMethodJO("getDecorView",Null)
        
            view.RunMethod("setSystemUiVisibility",Array(Bit.Or(0x00002000,view.RunMethod("getSystemUiVisibility",Null)))) 'Light style with black icons and text
        End If
    End If
after I remove the theme in the manifest and just using the above code, everything is working.
 
Top