3
我正在尝试进行自定义通知,并且它总是变得非常小(大多数通知的大小)。我可以看到Netflix和Youtube在投射到Chromecast设备时显示更大的通知,这些通知看起来很自定义(它们可能是大视图)。他们如何让他们成为那么大?自定义通知最大高度?
谢谢。
编辑:其标记为回答,因为评论指出bigContentView
我正在尝试进行自定义通知,并且它总是变得非常小(大多数通知的大小)。我可以看到Netflix和Youtube在投射到Chromecast设备时显示更大的通知,这些通知看起来很自定义(它们可能是大视图)。他们如何让他们成为那么大?自定义通知最大高度?
谢谢。
编辑:其标记为回答,因为评论指出bigContentView
的你似乎已经知道了......你可能会谈论大视图样式的通知。谷歌有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
。
是的我已经使用了Big View风格的通知,但我想我希望有一种方法可以使自定义通知成为Big View通知的大小。 – casolorz
啊,我明白了。你可以使用['bigContentView'](http://developer.android.com/reference/android/app/Notification.html#bigContentView)。 – kabuko
认为这是我需要的。谢谢。 – casolorz