我搜索了一种将视图放在 Android 通知栏上方的方法,例如 SwipePad 这就是我想要的(红色恐慌):
我已经测试了这段代码:
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);
但这只会给我:
绿条不在通知栏上方...
任何人都可以给我一个好方法吗?