WindowManager manager = ((WindowManager) context.getApplicationContext()
.getSystemService(Context.WINDOW_SERVICE));
WindowManager.LayoutParams localLayoutParams = new WindowManager.LayoutParams();
localLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
localLayoutParams.gravity = Gravity.TOP;
localLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|
// this is to enable the notification to recieve touch events
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON |
// Draws over status bar
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
localLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
manager.getDefaultDisplay().getHeight();
localLayoutParams.height = (int) (25 * context.getResources()
.getDisplayMetrics().scaledDensity);
localLayoutParams.format = PixelFormat.TRANSPARENT;
view = new customViewGroup(context);
manager.addView(view, localLayoutParams);
我的应用程序顶部按钮因顶部不可见click
而无法接收view
个事件。你可以建议一种我可以禁用status bar
的方法,而不会禁用应用程序的顶端吗?
答案 0 :(得分:0)
使用自定义主题隐藏状态栏。在styles.xml中创建一个自定义主题:
<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="@style/Theme.AppCompat">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
只需将其添加到AndroidManifest.xml中:
<application
...
...
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen">