简体   繁体   English

移动Android状态栏

[英]Move the Android Status Bar

I'm trying to move the status bar in Android (Froyo) from the top of the screen to the bottom of the screen. 我正在尝试将Android(Froyo)中的状态栏从屏幕顶部移动到屏幕底部。 I have done a lot of research but haven't found anyone who was successfully able to do this. 我做了很多研究,但没有找到任何能够成功做到这一点的人。

Side notes: I don't want to hide the status bar, I want to move it. 旁注:我不想隐藏状态栏,我想移动它。 Also, I'm not concerned if the status bar can no longer be expanded. 另外,我不担心状态栏是否无法再展开。 For this use case, it will never need to be. 对于这个用例,它永远不需要。

This is what I have done so far: 这是我到目前为止所做的:

  1. Looked at the status_bar.xml file in systemui/res/status_bar.xml but it only seems to define the layout WITHIN the status bar and not the status bar itself. 查看systemui/res/status_bar.xml中的status_bar.xml文件,但它似乎只在状态栏中定义了布局,而不是状态栏本身。
  2. Looked at systemui\\src\\com\\android\\systemui\\statusbar\\StatusBarService.java file. 查看systemui\\src\\com\\android\\systemui\\statusbar\\StatusBarService.java文件。
    • Around line 267, a StatusBarView is created from R.layout.status_bar (defined in the status_bar.xml file I referred to in above). 在第267行附近,从R.layout.status_bar创建了StatusBarView (在我上面提到的status_bar.xml文件中定义)。
    • Around line 330, a WindowManager.LayoutParams is instantiated and the gravity is set to Gravity.TOP . 在第330行附近,实例化WindowManager.LayoutParams并将重力设置为Gravity.TOP
    • The view and the WindowManager.LayoutParams are passed to WindowManagerImpl.getDefault().addView(view, lp) on line 341 at the end of addStatusBarView(). 视图和WindowManager.LayoutParams在addStatusBarView()末尾的第341行传递给WindowManagerImpl.getDefault().addView(view, lp) )。

Based on this, I changed the gravity of the WindowManager.LayoutParams to Gravity.BOTTOM. 基于此,我将WindowManager.LayoutParams的重力更改为Gravity.BOTTOM。 This DID work to some extent; 这个DID在某种程度上起作用; the status bar is at the bottom of the screen. 状态栏位于屏幕底部。 However, everything else that would normally be displayed underneath the status bar is still underneath the status bar - it gets pushed off the bottom of the screen. 但是,通常显示在状态栏下方的所有其他内容仍位于状态栏下方 - 它会被推离屏幕底部。 It's as if the rest of the screen is positioned relative to the status bar. 就像屏幕的其余部分相对于状态栏一样。

Can anyone provide any insight on what else I need to modify for this to work? 任何人都可以提供任何有关我需要修改的内容的见解吗?

The solution to this problem is as follows: 该问题的解决方案如下:

  1. Around line 345 of frameworks/base/services/java/com/android/server/status/StatusBarService.java change Gravity.TOP to Gravity.BOTTOM . frameworks/base/services/java/com/android/server/status/StatusBarService.java Gravity.TOP Gravity.BOTTOM更改为Gravity.BOTTOM
  2. Around line 1265 of frameworks/policies/base/phone/com/android/internal/policy/impl/PhoneWindowManager.java replace mDockTop = mContentTop = mCurTop = mStatusBar.getFrameLw().bottom with mContentBottom = mCurBottom = mStatusBar.getFrameLw().top . frameworks/policies/base/phone/com/android/internal/policy/impl/PhoneWindowManager.java替换mDockTop = mContentTop = mCurTop = mStatusBar.getFrameLw().bottom with mContentBottom = mCurBottom = mStatusBar.getFrameLw().top
  3. Around line 719 of frameworks/policies/base/mid/com/android/internal/policy/impl/MidWindowManager.java , replace mCurTop = mStatusBar.getFrameLw().bottom with mCurBottom = mStatusBar.getFrameLw().top . 周围的719线frameworks/policies/base/mid/com/android/internal/policy/impl/MidWindowManager.java ,取代mCurTop = mStatusBar.getFrameLw().bottommCurBottom = mStatusBar.getFrameLw().top

I tested this on Froyo in an emulator and it works fine. 我在模拟器中对Froyo进行了测试,效果很好。 The status bar is on the bottom, and everything else is above it. 状态栏位于底部,其他所有内容都位于其上方。 As I mentioned above, for my use case, I will never need to expand the status bar, so this is sufficient for me. 正如我上面提到的,对于我的用例,我永远不需要扩展状态栏,所以这对我来说已经足够了。 However, as @jkhouw1 mentioned, it's possible that the status bar could be made to expand upwards by modifying the logic in StatusBarService.java , particularly the performFling method on line 1159. 但是,正如@ jkhouw1所提到的,通过修改StatusBarService.java的逻辑,特别是第1159行的performFling方法,可以使状态栏向上扩展。

Hope someone finds this useful! 希望有人觉得这很有用!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM