菜鸟的安卓实习之路---微信悬浮窗通知窗口怎么做怎么做?
来源:互联网 发布:腾讯来电软件怎么回事 编辑:程序博客网 时间:2024/05/01 17:17
这几天,每当微信有新的通知,不论你在任何一个页面,别的引用的页面也好,都会在屏幕顶部出现一个悬浮窗,来显示收到消息,而不是很low的通知栏,这是怎么做的呢?
其实就是现实一个系统级的窗口:
核心代码:
public NotificationFloatingWindow(Context context, String operateMenu,String message) {this.inflater = LayoutInflater.from(context);<strong>popView = (LinearLayout) inflater.inflate(R.layout.notification_layout,null); //自己用xml定义窗口的样式</strong>popView.setOnClickListener(this);<strong>wm = (WindowManager) context.getApplicationContext().getSystemService("window"); //</strong>this.context = context;init(operateMenu);}public NotificationFloatingWindow(Context context,NotificationReference reference) {this.inflater = LayoutInflater.from(context);popView = (LinearLayout) inflater.inflate(R.layout.notification_layout,null);popView.setOnClickListener(this);wm = (WindowManager) context.getApplicationContext().getSystemService("window");this.context = context;init(reference);}每次显示的时候调用:
WindowManager.LayoutParams wmParams = new WindowManager.LayoutParams();<strong>wmParams.type = 2002; // type是关键,这里的2002表示系统级窗口,你也可以试试2003。</strong>wmParams.format = 1;wmParams.gravity = Gravity.TOP;wmParams.flags = 40;wmParams.width = WindowManager.LayoutParams.MATCH_PARENT;wmParams.height = WindowManager.LayoutParams.WRAP_CONTENT;<strong>wmParams.windowAnimations = R.style.notification_anim_style; //还可以自定义弹出,消失动画</strong>wm.addView(popView, wmParams);
2 0
- 菜鸟的安卓实习之路---微信悬浮窗通知窗口怎么做怎么做?
- 菜鸟的安卓实习之路----android控件自己做
- 微信营销怎么做?
- 微信营销怎么做
- 微信朋友圈的小视频播放怎么做的?
- 微信定制开发怎么做?
- 微信SEO怎么做呢?
- 微信预约系统怎么做?
- 怎么做我们自己的微信营销?
- 微信营销必须做,怎么做,步骤又是什么?
- 你客户的名片现在怎么处理?看看微信营销是怎么做的?
- 菜鸟的安卓实习之路---java的instance
- 菜鸟的安卓实习之路----开篇
- 菜鸟的安卓实习之路---布局思想
- 菜鸟的安卓实习之路---采用preferenceFragment布局
- 菜鸟的安卓实习之路---- setClickable和setEnabled
- 菜鸟的安卓实习之路---布局
- 菜鸟的安卓实习之路---layoutParams
- 梦江南(二首)
- LeetCode(75) Sort Colors
- 1008Maya Calendar
- MDI中重新排列view视口(子窗口)
- JSP入门
- 菜鸟的安卓实习之路---微信悬浮窗通知窗口怎么做怎么做?
- eclipse错误:java was started but returned exit code=-1073741510
- Foundation Framework 基本数据封装 NSNumber、NSValue、NSData
- AndroidMaterialDesign动画之Activity Transitions
- hdu 5319 Painter 2015 Multi-University Training Contest 3
- c# 反射
- 简单实用的 Ubuntu 快捷键
- 如何成为受市场欢迎的Android开发
- kettle各组件说明