简体   繁体   English

WhatsApp弹出通知如何工作?

[英]How does WhatsApp pop-up notification work?

I am trying to mimic the pop-up notification of WhatsApp. 我正在尝试模仿WhatsApp的弹出通知。 (If you have not seen it, it might be a bit hard for you to understand this.) Below is an image to give a clearer perspective. (如果您还没有看过,可能很难理解这一点。)下面是提供更清晰透视图的图像。

whatsapp弹出通知

Some suggested that this might be done using an oridnary activity which has the Theme.Holo.Light.Dialog.Alert theme. 有人建议可以使用具有Theme.Holo.Light.Dialog.Alert主题的Theme.Holo.Light.Dialog.Alert活动来完成此操作。 However, when I implemented that I got half of the activity full with the views (and the other half) which is supposed to be empty like a dialog, showing a white background. 但是,当我实现该功能时,活动的一半充满了视图(而另一半则充满了视图),这些视图本应像对话框一样为空,显示白色背景。 ie, I did not have the dialog feel. 即,我没有对话的感觉。

Morever, when the device is in standby mode (power button pressed) and locked, whatsapp is able to bypass that and show the popup dialog (or activity, or whatever) above that. 此外,当设备处于待机模式(按下电源按钮)并锁定时,whatsapp可以绕过该模式并在其上方显示弹出对话框(或活动或其他内容)。

Any ideas how to implement this ? 任何想法如何实现这一目标?

Oh god! 天啊! After hours, I found the solution! 几个小时后,我找到了解决方案!

Refer link: http://developer.android.com/guide/topics/ui/dialogs.html#CustomLayout 引用链接: http : //developer.android.com/guide/topics/ui/dialogs.html#CustomLayout

It's extremely easy, you just need to set up the theme of the activity to @android:style/Theme.Holo.Dialog in manifest like: 这非常容易,您只需在清单中将活动的主题设置为@android:style / Theme.Holo.Dialog即可,例如:

<activity android:theme="@android:style/Theme.Holo.Dialog" >

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM