[英]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: 这是我到目前为止所做的:
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文件,但它似乎只在状态栏中定义了布局,而不是状态栏本身。 systemui\\src\\com\\android\\systemui\\statusbar\\StatusBarService.java
file. systemui\\src\\com\\android\\systemui\\statusbar\\StatusBarService.java
文件。
StatusBarView
is created from R.layout.status_bar (defined in the status_bar.xml file I referred to in above). StatusBarView
(在我上面提到的status_bar.xml文件中定义)。 WindowManager.LayoutParams
is instantiated and the gravity is set to Gravity.TOP
. WindowManager.LayoutParams
并将重力设置为Gravity.TOP
。 WindowManagerImpl.getDefault().addView(view, lp)
on line 341 at the end of addStatusBarView(). 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: 该问题的解决方案如下:
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
。 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
。 frameworks/policies/base/mid/com/android/internal/policy/impl/MidWindowManager.java
, replace mCurTop = mStatusBar.getFrameLw().bottom
with mCurBottom = mStatusBar.getFrameLw().top
. frameworks/policies/base/mid/com/android/internal/policy/impl/MidWindowManager.java
,取代mCurTop = mStatusBar.getFrameLw().bottom
与mCurBottom = 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.