当前位置:   article > 正文

Android源码修改实现动态地隐藏和显示状态栏_onoverlaychangedlw

onoverlaychangedlw

修改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);
+		}
		//以下省略
		........
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

调用hideStatusBar方法,可实现动态显示和隐藏状态栏,隐藏是去掉状态栏高度的。状态栏是锁屏的一部分,这样修改不影响锁屏功能。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/635448
推荐阅读
相关标签
  

闽ICP备14008679号