Interesting notifications of Android animation effects: NiftyNotification (Android Toast alternative) and androidnotification

Source: Internet
Author: User

Interesting notifications of Android animation effects: NiftyNotification (Android Toast alternative) and androidnotification

The home page of a project on github for NiftyNotification is: https://github.com/sd6352051/NiftyNotification
Nitynotification itself depends on another third-party open-source project NineOldAndroids on github. The project home page of NineOldAndroids on github is: https://github.com/JakeWharton/NineOldAndroids
After NineOldAndroids is correctly referenced, you can directly use NiftyNotification. In a simple period, you can even directly download a single jar package of NiftyNotification and add it to your project libs, and then use it directly.
NiftyNotification does not need to configure xml files. You only need to write the upper-layer Java code like the native Toast of Android.

1 package com. gitonway. lee. niftynotification; 2 3 import android. app. activity; 4 import android. OS. bundle; 5 import android. view. view; 6 import com. gitonway. lee. niftynotification. lib. effects; 7 import com. gitonway. lee. niftynotification. lib. niftyNotificationView; 8 9 public class MainActivity extends Activity {10 private Effects effect; 11 12 @ Override13 protected void onCreate (Bundle savedInstanceSt Ate) {14 super. onCreate (savedInstanceState); 15 setContentView (R. layout. activity_main); 16} 17 18 public void showNotify (View v) {19 20 String msg = "today's weather is good and you are in a good mood! "; 21 22 switch (v. getId () {23 case R. id. scale: 24 effect = Effects. scale; 25 break; 26 case R. id. thumbSlider: 27 effect = Effects. thumbSlider; 28 break; 29 case R. id. jelly: 30 effect = Effects. jelly; 31 break; 32 case R. id. slidein: 33 effect = Effects. slideIn; 34 break; 35 case R. id. flip: 36 effect = Effects. flip; 37 break; 38 case R. id. slideOnTop: 39 effect = Effects. slideOnTop; 40 break; 41 case R. id. standard: 42 effect = Effects. standard; 43 break; 44} 45 46 NiftyNotificationView. build (this, msg, effect, R. id. mLyout ). setIcon (R. drawable. lion) // You47 // must48 // call49 // this50 // method51 // if52 // you53 // use54 // ThumbSlider55 // effect56. show (); 57 58 // You can configure like this59 // The default60 61 // Configuration cfg = new Configuration. builder () 62 //. setAnimDuration (700) 63 //. setDispalyDuration (1500) 64 //. setBackgroundColor ("# FFBDC3C7") 65 //. setTextColor ("# FF444444") 66 //. setIconBackgroundColor ("# FFFFFFFF") 67 //. setTextPadding (5) // dp68 //. setViewHeight (48) // dp69 //. setTextLines (2) // You had better use setViewHeight and setTextLines70 // together71 //. setTextGravity (Gravity. CENTER) // only text def72 // Gravity. CENTER, contain icon Gravity. CENTER_VERTICAL73 //. build (); 74 // 75 // NiftyNotificationView. build (this, msg, effect, R. id. mLyout, cfg) 76 //. setIcon (R. drawable. lion) // remove this line, only text77 //. setOnClickListener (new View. onClickListener () {78 // @ Override79 // public void onClick (View view) {80 // add your code81 //} 82 //}) 83 //. show (); // show (boolean) allow duplicates or showSticky () sticky84 // notification, you can call removeSticky () method close it85} 86 87}

Xml:

 1 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 2     xmlns:tools="http://schemas.android.com/tools" 3     android:layout_width="match_parent" 4     android:layout_height="match_parent" 5     android:background="#34495E" 6     android:orientation="vertical" 7     tools:context=".MainActivity"> 8  9     <TextView10         android:id="@+id/title"11         android:layout_width="match_parent"12         android:layout_height="48dp"13         android:background="#000000"14         android:textColor="#FFFFFF"15         android:gravity="center"16         android:text="Nifty Modal Notification Effects" />17     <ScrollView18         android:layout_width="match_parent"19         android:layout_height="wrap_content"20         android:layout_below="@+id/title"21         android:scrollbars="none">22         <LinearLayout23             android:layout_width="match_parent"24             android:layout_height="wrap_content"25             android:orientation="vertical"26             android:padding="5dp">27 28             <Button29                 android:id="@+id/scale"30                 style="@style/my_btn"31                 android:text="SCALE"32                 />33             <Button34                 android:id="@+id/thumbSlider"35                 style="@style/my_btn"36                 android:text="THUMB SLIDER"37                 />38             <Button39                 android:id="@+id/jelly"40                 style="@style/my_btn"41                 android:text="JELLY"42                 />43             <Button44                 android:id="@+id/slidein"45                 style="@style/my_btn"46                 android:text="SLIDE IN"47                 />48             <Button49                 android:id="@+id/flip"50                 style="@style/my_btn"51                 android:text="FLIP"52                 />53             <Button54                 android:id="@+id/slideOnTop"55                 style="@style/my_btn"56                 android:text="SLIDE ON TOP"57                 />58             <Button59                 android:id="@+id/standard"60                 style="@style/my_btn"61                 android:text="STANDARD"62                 />63         </LinearLayout>64     </ScrollView>65     <RelativeLayout66         android:id="@+id/mLyout"67         android:layout_below="@+id/title"68         android:layout_width="match_parent"69         android:layout_height="match_parent"70         android:clipChildren="true"71         >72 73     </RelativeLayout>74 </RelativeLayout>

Run:

 

Related Article

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.