简体   繁体   中英

How does WhatsApp pop-up notification work?

I am trying to mimic the pop-up notification of 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. 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.

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

It's extremely easy, you just need to set up the theme of the activity to @android:style/Theme.Holo.Dialog in manifest like:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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