Use notification to implement wide notification bar in Android (notification Example II)

Source: Internet
Author: User

Notification is a message that is displayed outside of your app's general interface. When the app sends a message to the system, the message is first displayed as a chart in the notification bar. To view the details of the message, you need to go to the notification drawer (notificationdrawer). Notification bar and Notification drawer

(notificationdrawer) are system-level controlled and you can view them at any time, without limiting the app.

Notification Design of:

As an important part of the Android UI, notification has its own design guidelines.

The notification interface elements in the notification drawer are notification in two ways, depending on your Android version and the status of the notification drawer:

(1) Normal view

This style is the standard display mode of notification drawer.

General View Post Link: http://www.cnblogs.com/panhouye/p/6139386.html

(2) Wide view

When your notification is expanded, it will show a larger view, which is a new feature after android4.1.

The following is a detailed description of the wide view:

The notification of this wide view will only appear when notification is expanded, and a normal notification can be expanded by gesture manipulation (some custom systems may not, and a wide view will be displayed directly). This style of notification has only been supported since android4.1. The following shows the inbox style of the notification:

You should have noticed that this kind of notification is actually not much different from normal,

The only difference is the number 7-detail area.

Different wide view notification here the display is different, there are several styles:

Large icon Style: The detail area shows a bitmap of the highest bit 256DP.

Text Style: Detail area displays a paragraph of text

message box style (Inbox style): The detail area displays several lines of text.

Here's what we'll show you this time:

The following starts the code implementation, here does not repeat the Click button layout, directly on the Java Notification Implementation code:

1  Public classMainactivityextendsappcompatactivity {2     Private Static Final intNo_2 =0x2;3 @Override4     protected voidonCreate (Bundle savedinstancestate) {5         Super. OnCreate (savedinstancestate);6 Setcontentview (r.layout.activity_main);7     }8     //How to click the button9      Public  voidShow (View v) {TenNotificationcompat.builder Builder =NewNotificationcompat.builder ( This); One Builder.setsmallicon (R.mipmap.guojia); ABuilder.setcontenttitle ("Guo Jia");//system limitations, may not be displayed -Builder.setcontenttext ("Let's play Yuan Shao");//system limitations, may not be displayed - builder.setdefaults (notification.default_all); the         //Add a wide view -Notificationcompat.inboxstyle style =NewNotificationcompat.inboxstyle (); -Style.setbigcontenttitle ("10 wins ten defeats"); -         //how much is displayed by phone screen pixels +Style.addline ("The first is Tao Sheng"); -Style.addline ("The second is righteousness wins"); +Style.addline ("The third is cure wins"); AStyle.addline ("The four is the victory"); atStyle.addline ("Five is to win"); -Style.addline ("Sixth is de Sheng"); -Style.addline ("Seventh is benevolence wins"); -Style.addline ("Eighth is Meanwin"); -Style.addline ("Nineth is Wen Sheng"); -Style.addline ("Tenth is Wusheng"); inStyle.setsummarytext ("Guo Jia");//Add a profile - Builder.setstyle (style); toNotification n =builder.build (); +Notificationmanager Manager =(Notificationmanager) Getsystemservice (context.notification_service); - manager.notify (no_2, n); the     } *}

Today, this is a simple demonstration of the implementation of the wide view of the notification, let's go to sleep and have a good night.

Use notification to implement wide notification bar in Android (notification Example II)

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.