本文介绍了将Android的状态栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从屏幕顶部的Andr​​oid(Froyo的)状态栏移动到屏幕的底部。我已经做了很多研究,但没有发现任何人谁是能够成功地做到这一点。

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 the status bar can no longer be expanded. For this use case, it will never need to be.

这是我迄今所做的:

  1. systemui / RES / status_bar.xml 看着status_bar.xml文件,但它似乎只定义布局中的状态栏,而不是状态栏本身。
  2. 看着 systemui的\ src \ COM \机器人\ systemui \状态栏\ StatusBarService.java 文件。
    • 内外线267,一个 StatusBarView 从R.layout.status_bar(在status_bar.xml文件我在上面提到的定义)创建的。
    • 内外线330, WindowManager.LayoutParams 被实例化和重力设置为 Gravity.TOP
    • 视图和WindowManager.LayoutParams传递给 WindowManagerImpl.getDefault()。addView(查看,LP)在线341处addStatusBarView的末尾()。
  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().

在此基础上,我改变了WindowManager.LayoutParams的重力Gravity.BOTTOM。这 DID 的工作在一定程度上;状态栏位于屏幕的底部。然而,其他一切通常会在状态栏下方显示的仍然是状态栏的下方 - 它就会被推离屏幕的底部。这是因为如果在屏幕的其余部分被定位成相对于状态栏。

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?

推荐答案

解决这个问题如下:

  1. 围绕框架/基/服务/爪哇/ COM /安卓/服务器/状态/ StatusBarService.java 变化的345行 Gravity.TOP Gravity.BOTTOM
  2. 细数框架/政策/基/电话/ COM /安卓/内部/政策/ IMPL / PhoneWindowManager.java 替换 mDockTop = 1265线mContentTop = mCurTop = mStatusBar.getFrameLw()。底部 mContentBottom = mCurBottom = mStatusBar.getFrameLw()。顶部
  3. 围绕框架/政策/基/中/ COM /安卓/内部/政策/ IMPL / MidWindowManager.java ,替换 mCurTop 719线= mStatusBar.getFrameLw()。底部 mCurBottom = mStatusBar.getFrameLw()。顶部
  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.

我在模拟器测试这对升级Froyo并能正常工作。状态栏是在底部,和其他一切都是在它上面。正如我上面提到的,对于我的使用情况下,我会永远需要扩展状态栏,所以这是够我。然而,正如@ jkhouw1提到的,它可能是状态栏可以进行向上扩展通过修改逻辑 StatusBarService.java ,特别是 performFling 上线1159的方法。

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.

希望有人认为这有用!

这篇关于将Android的状态栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 21:27