自定义通知最大高度?

cas*_*orz 6 android android-layout

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

谢谢。

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

kab*_*uko 3

您似乎已经知道...您可能正在谈论大视图样式通知。谷歌有专门的培训文档以及技术指南。这是那里的一些示例代码:

// 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);
Run Code Online (Sandbox Code Playgroud)

请注意对 的调用setStyle