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