对于出现的Andr​​oid prevent状态栏(修改)状态栏、Andr、oid、prevent

2023-09-12 04:02:59 作者:岁月轻狂

我在执行kiosk模式的应用程序,我已经成功地应用全屏无状态栏的外观交4.3,但不能因为当我们刷下来的顶部状态栏显示隐藏状态栏在4.3和4.4屏幕。

I am implementing a kiosk mode application and i have successfully made the application full-screen without status bar appearance post 4.3 but unable to hide status bar in 4.3 and 4.4 as status-bar appears when we swipe down at the top of the screen.

我试图让它全屏通过

speciflying全屏主题清单 在设置窗口标记IE setFlags setSystemUiVisibility

可能的复制,但没有找到具体的解决方案。

Possible duplicate but no concrete solution found

Permanently隐藏Android的状态栏

最后,我想的是,如何永久隐藏状态栏在一个活动的东西?在安卓4.3,4.4版本

推荐答案

我们无法prevent出现在全屏模式下的奇巧设备的状态,这样做仍然符合要求,即阻止从状态栏黑客扩大。

We could not prevent the status appearing in full screen mode in kitkat devices, so made a hack which still suits the requirement ie block the status bar from expanding.

有关的工作,该应用程序是不是做了充分的画面。我们把一个覆盖了状态栏和消耗所有输入事件。它$ P $从扩大pvented状态。

For that to work, the app was not made full screen. We put a overlay over status bar and consumed all input events. It prevented the status from expanding.

注意:的

note:

customViewGroup是它扩展的任何自定义类 布局(帧,相对布局等)和消费触摸事件。 要消耗触摸事件覆盖的onInterceptTouchEvent方法 视图组,返回true customViewGroup is custom class which extends any layout(frame,relative layout etc) and consumes touch event. to consume touch event override the onInterceptTouchEvent method of the view group and return true

更新

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/> 

的 customViewGroup实施 的

code:

WindowManager manager = ((WindowManager) 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_NOT_TOUCH_MODAL |

            // Draws over status bar
            WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;

    localLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
    localLayoutParams.height = (int) (50 * getResources()
            .getDisplayMetrics().scaledDensity);
    localLayoutParams.format = PixelFormat.TRANSPARENT;

    customViewGroup view = new customViewGroup(this);

    manager.addView(view, localLayoutParams);