0

I would like to know how can I set the status bar on transparent on Android with Nativescript ?

I read many post (How do I create a transparent Activity on Android?, https://blog.mindorks.com/how-to-create-a-transparent-activity-in-android...) but the status bar is always Grey or not transparence.

In values/styles.xml I added this :

<style name="Theme.AppCompat.Transparent.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:backgroundDimEnabled">false</item>
</style>

In AndroidManifest.xml

<activity
            android:name="com.tns.NativeScriptActivity"
            android:label="@string/title_activity_kimera"
            android:configChanges="keyboard|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|locale|uiMode"
            android:theme="@style/Theme.AppCompat.Transparent.NoActionBar">

I'm confuse because it's like very easy. Maybe it's different on nativescript ?

I look this video https://www.youtube.com/watch?v=NroxMDGOJ_E but if I set this color "#00000000" or "@android:color/transparent" on ns_primaryDark it doesn't work.

Jérémie Chazelle
  • 1,721
  • 4
  • 32
  • 70
  • Just setting `android:windowIsTranslucent` to `true` in styles xml works perfectly on my end. If you have issues, please share a git repo. – Manoj May 01 '20 at 02:25

2 Answers2

0
  • page.xml
  • page.js
  • page.css

Tested in Nativescript 6, Try this in your page's corresponding nativescript CSS file:

ActionBar {
   opacity: 0;
}

0 here is complete transparency, where 0.5 is half transparent, and 1 is show the Actionbar completely.

A clean way to hide the actionbar is to just go to the javascript page, though:

exports.loaded = function (args) {
    page = args.object;
    page.actionBarHidden = true;
}

and in your XML page we add the loaded function that will receive the event, and the page, and hide that pages actionbar based on the attribute of "actionBarHidden":

<Page loaded="loaded">
<Page>
halfer
  • 19,824
  • 17
  • 99
  • 186
gnu_byte
  • 41
  • 1
  • 5
0

Maybe this might be of some help then?

https://github.com/PeterStaev/NativeScript-Status-Bar

// Get reference to the Status Bar plugin module
import statusBar = require("nativescript-status-bar");

exports.loaded = function() {
    statusBar.hide();
}
gnu_byte
  • 41
  • 1
  • 5