Android development-detailed description of various styles of Notification,

Source: Internet
Author: User

Android development-detailed description of various styles of Notification,

I wanted to write it together with the previous instructions on using Notification notifications. I checked the materials and thought it was necessary to explain the Style part separately.

Previous: Android development-Notification usage and NotificationCopat. Builder APIs

 

The previous article also introduced two commonly used styles. This is the content before the extension.

BigTextStyle

After reading the information on the Internet, it seems that the text set in bigText is displayed only when you click the message in the notification bar in the previous version. However, when I tried it, I found that it was directly displayed, it replaces both setContentTitle and setContentText, bigText with contentText, and bigcontentTitle with ContentTitle.

Android. support. v4.app. icationicationcompat. bigTextStyle style = new android. support. v4.app. icationicationcompat. bigTextStyle (); style. bigText ("here is the body to be displayed after the notification is clicked. You can use line breaks to display a long, long
Long long); style. setBigContentTitle ("title after clicking"); // SummaryText is useless. You can leave style unspecified. setSummaryText ("only one line of text at the end ");

Then, you can directly call setStyle and pass the style as a parameter.

 

BigPictureStyle

The main method is the bigPicture method. The other two are similar to the previous BigText method, and the original one is replaced, but it will not be replaced if it is not set.

android.support.v4.app.NotificationCompat.BigPictureStyle style = new android.support.v4.app.NotificationCompat.BigPictureStyle();style.setBigContentTitle("BigContentTitle");style.setSummaryText("SummaryText");style.bigPicture(BitmapFactory.decodeResource(getResources(),R.drawable.small));

 

InboxStyle

 When the content of each line is too long, it does not automatically wrap the line. Similar to BigText, if it is set, it will replace the original ContentText and Title.

Android. support. v4.app. icationicationcompat. inboxStyle style = new android. support. v4.app. icationicationcompat. inboxStyle (); style. setBigContentTitle ("BigContentTitle "). addLine ("first row, first row "). addLine ("second line "). addLine ("third line "). addLine ("fourth line "). addLine ("fifth line "). setSummaryText ("SummaryText ");

 

MessageingStyle

Message notification to quickly reply to the message notification. It seems that Android N and above can be used. Currently, the testing machine on hand is of a lower version and there is no quick response operation item.

 

DecoratedCustonViewStyleDecoratedMediaCustonViewStyleMediaStyle

Multimedia playback notifications and quick multimedia operation controls. You can customize the content of the operation control to be displayed.

  • SetShowActionsInCompactView

  • SetMediaSession

  • SetShowCancelButton

  • SetCancelButtonInten

 

Builder. addAction (android. r. drawable. ic_media_rew, "", null); builder. addAction (android. r. drawable. ic_media_play, "", null); builder. addAction (android. r. drawable. ic_media_ff, "", null); icationicationcompat. mediaStyle mediaStyle = new NotificationCompat. mediaStyle (); mediaStyle. setShowActionsInCompactView (0, 1, 2); mediaStyle. setShowCancelButton (true); builder. setStyle (mediaStyle );

Er, it seems that I have deviated from the topic, and the Notification is too deep. I wrote it here first, and these functions are useless. I feel that learning it doesn't make much sense, just give up now!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.