实现展开和折叠通知Android [英] Implement expand and collapse notification android
问题描述
我需要在状态栏中为Android 4.0及更高版本实现展开和折叠通知.我已经在Google上搜索了此内容,但没有得到任何实现的代码解决方案,有人知道如何实现这一点吗?
I need to implement expand and collapse notification in status bar for android 4.0 and above version. I have search on google for this but didn't getting any code solution for implementation does anybody have I idea how to implement this
提前谢谢
推荐答案
可扩展的 Notification
是 Notification
An expandable Notification
is a special case of a Notification
Big View
. If the Big View
is not at the top of the notification drawer, it it shown 'closed' and is expandable by swipe. Quote from Android Developers:
仅当扩展通知时才会显示通知的大视图,当通知位于通知抽屉的顶部或用户使用手势扩展通知时会发生.从Android 4.1开始提供扩展的通知.
A notification's big view appears only when the notification is expanded, which happens when the notification is at the top of the notification drawer, or when the user expands the notification with a gesture. Expanded notifications are available starting with Android 4.1.
可以按如下方式创建 Big View
Notification
:
The Big View
Notification
can be created as follows:
Notification notification = new Notification.BigTextStyle(builder)
.bigText(myText).build();
或
Notification notification = new Notification.BigPictureStyle(builder)
.bigPicture(
BitmapFactory.decodeResource(getResources(),
R.drawable.my_picture)).build();
此处是一个教程.
这篇关于实现展开和折叠通知Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!