有一個點要特別注意,就是!安卓版本要5.0以上 。css
參考文章:http://www.javashuo.com/article/p-bksoncyp-ch.htmlhtml
其中頭兩項是修改MainActivity.java文件,如下是修改後的MainActivity.java文件的全部內容java
MainActivity.java的路徑爲:platforms\android\src\com\ionicframework\android
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License atexpress
http://www.apache.org/licenses/LICENSE-2.0apache
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/segmentfault
package com.ionicframework.smartwms328018;app
import android.os.Bundle;
import org.apache.cordova.*;
import android.os.Build;
import android.view.View;less
public class MainActivity extends CordovaActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Set by <content src="index.html" /> in config.xml
//安卓狀態欄透明
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
}
loadUrl(launchUrl);
}
}ionic
第二步:在項目根目錄的config.xml文件中添加下面配置,這裏須要注意
顏色的設置相當重要,此處是八位hex color,前兩位是透明度,後六位是rgb顏色值.so根據本身的須要配置.<preference name="StatusBarBackgroundColor" value="#551b1d23" />
第三步: 在app.scss中添加樣式
.platform-android { ion-header { padding-top: $cordova-md-statusbar-padding; background-color: color($colors, primary); } }