Hi to all. Sorry for my English
Help me plz doing Status Bar with transparent background and white text for ios and android.
When i used any code from this documentation (https://ionicframework.com/docs/v2/native/status-bar/), on ios he becomes only with white background and white text.
Can you please share what you want to achieve? Also, what code have you tried already?
Everything is ok now. I looked through in app Ionic View
This is for those who needed the answer on how to implement this in Ionic2 for Android:
- On MainActivity java file on Android platform folder, paste the following code after super.onCreate() (thanks @saademotion_dev):
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); //Status bar color, set to whatever opacity/color you want getWindow().setStatusBarColor( ContextCompat.getColor(this, R.color.status_bar_transparet)); }
- On the variables.scss inside the theme folder, have this included on the Material Design section:
.platform-android5 {
ion-header {
margin-top: 20px;
}
}.platform-android6 {
ion-header {
margin-top: 20px;
}
}.platform-android7 {
ion-header {
margin-top: 20px;
}
}
- Lastly, on your config.xml file on the root, add an alpha channel on your existing status bar color:
<preference name="StatusBarBackgroundColor" value="#551b1d23" />
Thatâs it folks, you have your status bar transparent for your Ionic2 app. Hope that helps everyone using Ionic2.
ok thank you so much for this response.
Hi, After i add these code to MainActivity.java in CORDOVA
I got error: âpackage Build does not existâ whene build the app.
How can i fix this error?
same hereâŚ
/Users/leo/Documents/myApp/platforms/android/src/com/ionicframework/myapp635554/MainActivity.java:35: error: cannot find symbol
Hi,all
I solved it.
(thans @peterbetos @saademotion_dev)
Firstly, Please distinguish between toolBar and statusBar.The discussion hear is about statusBar.
So,
You can simply use cordova-plugin-statusbar StatusBar.styleBlackTranslucent()
achieve it on IOS and WP. Thatâs ok.But android is so poorâŚ
Donât worry!If you want a Translucent statusBar for android or another platforms.Look at the following demo.
Awesome!
Upgrade to Ionic 3+
I did some work so that each platform did not affect each other⌠Learn more
Works perfectly! Thanks!
C:\Users\Admin\sample_Amber\platforms\android\src\amber\company\com\MainActivity.java:37: error: package Build does not exist
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
^
C:\Users\Admin\sample_Amber\platforms\android\src\amber\company\com\MainActivity.java:37: error: package Build does not exist
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
^
Note: C:\Users\Admin\sample_Amber\platforms\android\src\org\apache\cordova\splashscreen\SplashScreen.java uses or overrides a deprecated API.
:compileDebugJavaWithJavac FAILED
How can i fix this error?
same problem for me âŚhow could you resolve?
Remember to add these packages in MainActivity.java.
import android.os.Build;
import android.view.View;
Hi can I install this using npm, I canât make it work. Already git clone but when I run npm install, its not installing.
Same here, bad documentation.
Try this and hope it will work for you
Status Bar
$ ionic cordova plugin add cordova-plugin-statusbar
$ npm install @ionic-native/status-bar@beta
app.component.ts
import { StatusBar } from â@ionic-native/status-bar/ngxâ;
constructor(
private statusBar: StatusBar
) {
this.platform= platform;
this.platform.ready().then( () => {
this.statusBar.overlaysWebView(false);
this.statusBar.backgroundColorByHexString(â#30cfd0â);
});
}
app.module.ts
import { StatusBar } from â@ionic-native/status-bar/ngxâ;
providers: [StatusBar]
color is changing but not getting transparentâŚ
For Android check this solution