gpt4 book ai didi

android - 在通知栏上方添加 View

转载 作者:行者123 更新时间:2023-11-29 14:17:50 25 4
gpt4 key购买 nike

我搜索了一种将 View 放在 Android 通知栏上方的方法,例如 SwipePad这就是我想要的(红色 panic ): enter image description here

我已经测试了这段代码:

    setContentView(R.layout.main);

View disableStatusBar = new View(this);
disableStatusBar.setBackgroundColor(Color.GREEN);

WindowManager.LayoutParams handleParams = new WindowManager.LayoutParams(
WindowManager.LayoutParams.FILL_PARENT,
50,
// This allows the view to be displayed over the status bar
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,//or other type_system make same
// this is to keep button presses going to the background window
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
// this is to enable the notification to recieve touch events
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
// Draws over status bar
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
PixelFormat.TRANSLUCENT);

handleParams.gravity = Gravity.TOP;
getWindow().addContentView(disableStatusBar, handleParams);

但这只会给我:enter image description here

绿条不在通知栏上方...

谁能告诉我好方法?

最佳答案

我使用这个解决方案:

 final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
|WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
PixelFormat.TRANSLUCENT);

关于android - 在通知栏上方添加 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12466210/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com