创建UI或小工具,看到在所有的Andr​​oid应用程序的顶部? [英] Create a UI or a widget that sees on top of all Application in Android?

查看:118
本文介绍了创建UI或小工具,看到在所有的Andr​​oid应用程序的顶部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以创建一个用户界面或Android的一个小工具,将被视为对所有应用程序的顶部?该<一href="https://play.google.com/store/apps/details?id=com.liveov.shotux&feature=search_result#?t=W251bGwsMSwxLDEsImNvbS5saXZlb3Yuc2hvdHV4Il0.">Screenshot UX 应用程序有这样一个小部件,将有看到上面所有的应用程序,当点击它会捕捉到画面的相机图标。

Can I create a UI or a widget in android that will be seen on top of all applications? The Screenshot UX application has a widget like this, There will be a camera icon seen on top of all application, when clicked it will capture the screen.

推荐答案

如果您只想显示的东西,你可以在一切之上显示它甚至是锁屏。

If you want to just display something, you can display it on top of everything even the lockscreen.

如果你想要的东西被点击,你可以在任何除锁屏上面显示出来。

If you want something to be clickable, you can display it on top of anything except the lockscreen.

下面是一个示例,修改你的需求:

Here's a sample, modify to your needs:

创建服务,并做到以下几点:

Create a service and do the following:

//These three are our main components.
WindowManager wm;
LinearLayout ll;
WindowManager.LayoutParams ll_lp;

//Just a sample layout parameters.
ll_lp = new WindowManager.LayoutParams();
ll_lp.format = PixelFormat.TRANSLUCENT;
ll_lp.height = WindowManager.LayoutParams.FILL_PARENT;
ll_lp.width = WindowManager.LayoutParams.FILL_PARENT;
ll_lp.gravity = Gravity.CLIP_HORIZONTAL | Gravity.TOP;

//This one is necessary.
ll_lp.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;

//Play around with these two.
ll_lp.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
ll_lp.flags = ll_lp.flags | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;

//This is our main layout.
ll = new LinearLayout(this);
ll.setBackgroundColor(android.graphics.Color.argb(0, 0, 0, 0));
ll.setHapticFeedbackEnabled(true);

//And finally we add what we created to the screen.
wm.addView(ll, ll_lp);

这篇关于创建UI或小工具,看到在所有的Andr​​oid应用程序的顶部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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