自定义通知最大高度?

时间:2014-01-09 23:47:14

标签: android android-layout

我正在尝试制作自定义通知,但它总是很小(大约是大多数通知的大小)。我可以看到Netflix和Youtube在投射到chromecast设备时会显示更大的通知,这些通知看起来是自定义的(它们可能是大视图)。他们如何让他们变得那么大?

感谢。

编辑:由于评论指出bigContentView

,将其标记为已回答

1 个答案:

答案 0 :(得分:3)

您似乎已经知道了...您可能正在谈论大视图样式通知。谷歌有specific training documentation以及a technical guide。以下是一些示例代码:

// 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);

请注意对setStyle的调用。