Android Question Transparent Status Bar

Keith Yong

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

  • Screen Shot 2019-03-06 at 4.19.49 PM.png
    Screen Shot 2019-03-06 at 4.19.49 PM.png
    200 KB · Views: 457
  • Screen Shot 2019-03-06 at 4.20.03 PM.png
    Screen Shot 2019-03-06 at 4.20.03 PM.png
    89 KB · Views: 449

Keith Yong

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

  • Screen Shot 2019-03-06 at 11.44.03 PM.png
    Screen Shot 2019-03-06 at 11.44.03 PM.png
    207.4 KB · Views: 341
Upvote 0

Keith Yong

Active Member
Licensed User
Longtime 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?
 
Upvote 0

Keith Yong

Active Member
Licensed User
Longtime 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.
 
Upvote 0
Top