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:
- 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. - 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 toGravity.TOP
. - The view and the WindowManager.LayoutParams are passed to
WindowManagerImpl.getDefault().addView(view, lp)
on line 341 at the end of addStatusBarView().
- Around line 267, a
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:
- Around line 345 of
frameworks/base/services/java/com/android/server/status/StatusBarService.java
changeGravity.TOP
toGravity.BOTTOM
. - Around line 1265 of
frameworks/policies/base/phone/com/android/internal/policy/impl/PhoneWindowManager.java
replacemDockTop = mContentTop = mCurTop = mStatusBar.getFrameLw().bottom
withmContentBottom = mCurBottom = mStatusBar.getFrameLw().top
. - Around line 719 of
frameworks/policies/base/mid/com/android/internal/policy/impl/MidWindowManager.java
, replacemCurTop = mStatusBar.getFrameLw().bottom
withmCurBottom = 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!
精彩评论