如何建立在所有其它窗口的Andr​​oid顶部的窗口 [英] How to build a window on the top of all others window on Android

查看:240
本文介绍了如何建立在所有其它窗口的Andr​​oid顶部的窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要建立在每个窗口的顶部视图。

I want to build a view on the top of every window.

我发现这个code:

bt = new Button(getApplicationContext());
LayoutParams param = new LayoutParams();
param.flags = LayoutParams.FLAG_NOT_FOCUSABLE;
param.format = PixelFormat.RGBA_8888;
param.type = LayoutParams.TYPE_SYSTEM_ALERT;
param.gravity = Gravity.TOP | Gravity.LEFT;
param.width = 40;
param.height = 40;
wmgr = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
wmgr.addView(bt, param);

的manifest.xml

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

该视图建立,但是当我preSS home键,我看不到,除了在状态栏任何东西。

The view is built but when I press the home button, I can't see anything except the status bar.

有什么不对?请帮我。

推荐答案

修改

wmgr = (WindowManager) getSystemService(Context.WINDOW_SERVICE); 

wmgr = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE);

这篇关于如何建立在所有其它窗口的Andr​​oid顶部的窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆