In order to appear the 3 lines of text plus the text "info" has to do so :
Notification notif = new NotificationCompat.Builder(this)
.setContentTitle("Title")
.setContentText("Text")
.setSubText("SubText")
.setContentInfo("info")
By setting Bigpicturestyle like this:
NotificationCompat.BigPictureStyle big = new NotificationCompat.BigPictureStyle();
big.bigPicture(bitMap)
.setBigContentTitle("BIG TITLE")
.setSummaryText("SUMMARY");
When the Notification is expanded:
- the text "Title" is replaced by "BIG TITLE"
- the text "Text" is maintained.
- the text "Subtext" is replaced by "SUMMARY"
It is also possible to create custom Notifications using a Remoteviews passing it on to the method setContent()
of Notification.Builder
Define your layout in the usual way in a xml, then build the Notification this way:
RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.customnotification);
Notification.Builder builder = new Notification.Builder(this)
...
...
...
.setContent(remoteViews);
Use the various methods provided by the class Remoteviews to access the views of layout.
For example remoteViews.setOnClickPendingIntent(R.id.button1, intent);
assigns a pendingIntent to the button button1
Am I beginner as I would make this layout? Do you have any examples? How could you put buttons like the example above with this transparent background bar? Another detail as you would for the text to be in Multiple Lines?
– William
The layout is done in the same way as if it were for an Activity. Multiple lines are multiple Textview
– ramaral
I edited the answer with explanation to get 3 lines of text
– ramaral
was perfect, it was exactly these 3 lines I needed. Now yes meets me perfectly, thank you very much for the solution given. Great hug
– William