Android 8.1 中Systemui中的常见修改 更改横屏状态下的NavigationBar位置

经过调整,使得NavicationBar在手机界面的左侧。主要思路分为两步,调整NavitationBar的位置,二是调整view的起始点。

frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java

diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 0468ca5..3dd17ff 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -4670,15 +4670,24 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                 // Landscape screen; nav bar goes to the right.
                 int left = displayWidth - overscanRight
                         - getNavigationBarWidth(displayRotation, uiMode);
-                mTmpNavigationFrame.set(left, 0, displayWidth - overscanRight, displayHeight);
-                mStableRight = mStableFullscreenRight = mTmpNavigationFrame.left;
+                //mTmpNavigationFrame.set(left, 0, displayWidth - overscanRight, displayHeight);
+                // mStableRight = mStableFullscreenRight = mTmpNavigationFrame.left;
+                //modify by xiangzaixiansheng for UI
+	        int right = overscanLeft + getNavigationBarWidth(displayRotation, uiMode);//计算导航栏大小和显示位置
+                mTmpNavigationFrame.set(overscanLeft, 0, right, displayHeight);
+                mStableLeft = mStableFullscreenLeft = mTmpNavigationFrame.right;				
+
                 if (transientNavBarShowing) {
                     mNavigationBarController.setBarShowingLw(true);
                 } else if (navVisible) {
                     mNavigationBarController.setBarShowingLw(true);
-                    mDockRight = mTmpNavigationFrame.left;
-                    mRestrictedScreenWidth = mDockRight - mRestrictedScreenLeft;
-                    mRestrictedOverscanScreenWidth = mDockRight - mRestrictedOverscanScreenLeft;
+                   // mDockRight = mTmpNavigationFrame.left;
+                   // mRestrictedScreenWidth = mDockRight - mRestrictedScreenLeft;
+                   // mRestrictedOverscanScreenWidth = mDockRight - mRestrictedOverscanScreenLeft;
+                   mDockLeft = mTmpNavigationFrame.right;
+		   mRestrictedScreenWidth = displayWidth - mDockLeft;
+		   mRestrictedOverscanScreenWidth = displayWidth ;
                 } else {
                     // We currently want to hide the navigation UI - unless we expanded the status
                     // bar.
@@ -4690,7 +4699,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                     // If the nav bar is currently requested to be visible,
                     // and not in the process of animating on or off, then
                     // we can tell the app that it is covered by it.
-                    mSystemRight = mTmpNavigationFrame.left;
+                   // mSystemRight = mTmpNavigationFrame.left;
+                   mSystemLeft = mTmpNavigationFrame.right;
                 }
             } else if (mNavigationBarPosition == NAV_BAR_LEFT) {
                 // Seascape screen; nav bar goes to the left.
@@ -4729,7 +4739,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
             mStatusBarLayer = mNavigationBar.getSurfaceLayer();
             // And compute the final frame.
             mNavigationBar.computeFrameLw(mTmpNavigationFrame, mTmpNavigationFrame,
-                    mTmpNavigationFrame, mTmpNavigationFrame, mTmpNavigationFrame, dcf,
+                    mTmpNavigationFrame, mTmpNavigationFrame,
+                    mTmpNavigationFrame, dcf,
                     mTmpNavigationFrame, mTmpNavigationFrame);
             if (DEBUG_LAYOUT) Slog.i(TAG, "mNavigationBar frame: " + mTmpNavigationFrame);
             if (mNavigationBarController.checkHiddenLw()) {
@@ -5229,7 +5240,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                     pf.bottom = df.bottom = of.bottom = cf.bottom = mUnrestrictedScreenTop
                             + mUnrestrictedScreenHeight;
                 } else if ((sysUiFl & View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN) != 0) {
-                    pf.left = df.left = of.left = mRestrictedScreenLeft;
+                   // pf.left = df.left = of.left = mRestrictedScreenLeft;
+                   //modify by xiangzaixiansheng
+                    pf.left = df.left = of.left = cf.left = mRestrictedScreenLeft-mTmpNavigationFrame.right;
                     pf.top = df.top = of.top  = mRestrictedScreenTop;
                     pf.right = df.right = of.right = mRestrictedScreenLeft + mRestrictedScreenWidth;
                     pf.bottom = df.bottom = of.bottom = mRestrictedScreenTop

 

  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 8
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值