修改PhoneWindowManager.java:
+ public void hideStatusBar(boolean hide) {
+ mHideStatusBar = hide;
+ onOverlayChangedLw();
+ }
@Override
public void onOverlayChangedLw() {
onConfigurationChanged();
}
@Override
public void onConfigurationChanged() {
Context uiContext = getSystemUiContext();
final Resources res = uiContext.getResources();
+ if(mHideStatusBar) {
+ mStatusBarHeightForRotation[mPortraitRotation] =
+ mStatusBarHeightForRotation[mUpsideDownRotation] = 0;
+ mStatusBarHeightForRotation[mLandscapeRotation] =
+ mStatusBarHeightForRotation[mSeascapeRotation] = 0;
+ } else {
mStatusBarHeightForRotation[mPortraitRotation] =
mStatusBarHeightForRotation[mUpsideDownRotation] = res.getDimensionPixelSize(
com.android.internal.R.dimen.status_bar_height_portrait);
mStatusBarHeightForRotation[mLandscapeRotation] =
mStatusBarHeightForRotation[mSeascapeRotation] = res.getDimensionPixelSize(
com.android.internal.R.dimen.status_bar_height_landscape);
+ }
//以下省略
........
}
调用hideStatusBar方法,可实现动态显示和隐藏状态栏,隐藏是去掉状态栏高度的。状态栏是锁屏的一部分,这样修改不影响锁屏功能。