开发者

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. 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 th开发者_StackOverflow中文版e 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.
  2. Looked at systemui\src\com\android\systemui\statusbar\StatusBarService.java file.
    • Around line 267, a StatusBarView is created from R.layout.status_bar (defined in the status_bar.xml file I referred to in above).
    • Around line 330, a WindowManager.LayoutParams is instantiated and the gravity is set to Gravity.TOP.
    • The view and the WindowManager.LayoutParams are passed to WindowManagerImpl.getDefault().addView(view, lp) on line 341 at the end of addStatusBarView().

Based on this, I changed the gravity of the WindowManager.LayoutParams to Gravity.BOTTOM. This DID work to some extent; 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.
  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.
  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.

I tested this on Froyo in an emulator and it works fine. 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.

Hope someone finds this useful!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜