android ui 小应用,如何在Android中创建位于所有应用程序之上的UI或窗口小部件?...

如果您只想显示某些内容,即使是锁屏也可以显示在所有内容之上.

如果您想要点击某些内容,可以将其显示在除锁定屏幕之外的任何内容上.

这是一个示例,根据您的需求进行修改:

创建服务并执行以下操作:

//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);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值