自定义通知最大高度? [英] Custom notification maximum height?

查看:129
本文介绍了自定义通知最大高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使自定义通知,它总是最终被pretty小(对大多数通知的大小)。我可以看到,Netflix和YouTube上显示更大的通知看起来定制铸造Chromecast的设备时(他们可能是大视图)。他们是如何使他们的大?

感谢。

编辑:将其标记为回答因为评论指出 bigContentView


解决方案

您似乎已经知道了......你可能在谈论大视图样式的通知。谷歌已经具体的培训文档还有的对于一个技术指南。下面是一些例子code从那里:

  //构造建造对象。
NotificationCompat.Builder建设者=
        新NotificationCompat.Builder(本)
        .setSmallIcon(R.drawable.ic_stat_notification)
        .setContentTitle(的getString(R.string.notification))
        .setContentText(的getString(R.string.ping))
        .setDefaults(Notification.DEFAULT_ALL)//需要VIBRATE权限
        / *
         *将大观大文本的风格并提供
         将要显示*文本(用户的提醒消息)
         *在展开的通知的详细信息区域。
         *这些调用由支持库忽略
         * pre-4.1设备。
         * /
        .setStyle(新NotificationCompat.BigTextStyle()
                .bigText(MSG))
        .addAction(R.drawable.ic_stat_dismiss,
                的getString(R.string.dismiss),piDismiss)
        .addAction(R.drawable.ic_stat_snooze,
                的getString(R.string.snooze),piSnooze);

请注意调用的setStyle

I am trying to make a custom notification and it always ends up being pretty small (about the size of most notifications). I can see that Netflix and Youtube display much larger notifications which look custom (they might be big view) when casting to a chromecast device. How are they making them that large?

Thanks.

EDIT: Marked it as answered because of the comment pointing out bigContentView

解决方案

You seem to already know... You're probably talking about big view style notifications. Google has specific training documentation as well as a technical guide for that. Here's some example code from there:

// Constructs the Builder object.
NotificationCompat.Builder builder =
        new NotificationCompat.Builder(this)
        .setSmallIcon(R.drawable.ic_stat_notification)
        .setContentTitle(getString(R.string.notification))
        .setContentText(getString(R.string.ping))
        .setDefaults(Notification.DEFAULT_ALL) // requires VIBRATE permission
        /*
         * Sets the big view "big text" style and supplies the
         * text (the user's reminder message) that will be displayed
         * in the detail area of the expanded notification.
         * These calls are ignored by the support library for
         * pre-4.1 devices.
         */
        .setStyle(new NotificationCompat.BigTextStyle()
                .bigText(msg))
        .addAction (R.drawable.ic_stat_dismiss,
                getString(R.string.dismiss), piDismiss)
        .addAction (R.drawable.ic_stat_snooze,
                getString(R.string.snooze), piSnooze);

Note the call to setStyle.

这篇关于自定义通知最大高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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