如何在Android中创建自定义通知 [英] How to create Custom Notification in android

查看:627
本文介绍了如何在Android中创建自定义通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个自定义通知,而不是android中的默认通知. 当前通知中的图标,标题和消息如下图所示

I need to create a custom notification instead of the default notification in android. Current notification have a icon,heading and message like below image

我要这样自定义

我该如何实现

推荐答案

通知视图

普通视图-普通视图中的通知会显示在最高64 dp高的区域中.即使您创建具有大视图样式的通知,该通知也将以普通视图显示,直到展开为止.

Normal View - A notification in normal view appears in an area that’s up to 64 dp tall. Even if you create a notification with a big view style, it will appear in normal view until it’s expanded.

Content title
Large icon
Content text
Content info
Small icon
Notification time

普通视图喜欢

大视图-通知的大视图仅在扩展通知时才会出现,这种情况发生在通知位于通知抽屉的顶部或用户使用手势扩展通知时.扩展的通知最初是在Android 4.1 JellyBean [API 16]中引入的. Expandable notifications旨在支持称为Notification.Style的丰富通知样式对象.

Big View - 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 were first introduced in Android 4.1 JellyBean [API 16]. Expandable notifications were designed to support rich notification style objects called Notification.Style.

喜欢大视角的人

转到此链接 expandable-notifications-android

有关官方文档

这篇关于如何在Android中创建自定义通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆