NiftyNotification在github上的项目主页是:https://github.com/sd6352051/NiftyNotification
NiftyNotification本身又依赖于另外一个github上的第三方开源项目NineOldAndroids,NineOldAndroids在github上的项目主页是:https://github.com/JakeWharton/NineOldAndroids
正确添加NineOldAndroids引用后,即可直接使用NiftyNotification。简单期间,甚至可以直接将NiftyNotification的单个jar包下载后加入到自己的项目libs中,然后直接使用。
NiftyNotification无需配置xml文件,只需像Android原生的Toast那样写上层Java代码即可,NiftyNotification的Java代码写法简单,可设置的参数丰富,可定制性强,摘录NiftyNotification项目中的部分Java代码示例:

activity_main.xml:

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#34495E"
android:orientation="vertical"
tools:context=".MainActivity" > <TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#000000"
android:gravity="center"
android:text="Nifty Modal Notification Effects"
android:textColor="#FFFFFF" /> <ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/title"
android:scrollbars="none" > <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp" > <Button
android:id="@+id/scale"
style="@style/my_btn"
android:text="SCALE" /> <Button
android:id="@+id/thumbSlider"
style="@style/my_btn"
android:text="THUMB SLIDER" /> <Button
android:id="@+id/jelly"
style="@style/my_btn"
android:text="JELLY" /> <Button
android:id="@+id/slidein"
style="@style/my_btn"
android:text="SLIDE IN" /> <Button
android:id="@+id/flip"
style="@style/my_btn"
android:text="FLIP" /> <Button
android:id="@+id/slideOnTop"
style="@style/my_btn"
android:text="SLIDE ON TOP" /> <Button
android:id="@+id/standard"
style="@style/my_btn"
android:text="STANDARD" />
</LinearLayout>
</ScrollView> <RelativeLayout
android:id="@+id/mLyout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/title"
android:clipChildren="true" >
</RelativeLayout> </RelativeLayout>

MainActivity.java:

 package com.gitonway.lee.niftynotification;

 import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.Toast; import com.gitonway.lee.niftynotification.lib.Configuration;
import com.gitonway.lee.niftynotification.lib.Effects;
import com.gitonway.lee.niftynotification.lib.NiftyNotificationView; public class MainActivity extends Activity {
private Effects effect; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
} public void showNotify(View v){ String msg="Today we’d like to share a couple of simple styles and effects for android notifications."; switch (v.getId()){
case R.id.scale:effect=Effects.scale;break;
case R.id.thumbSlider:effect=Effects.thumbSlider;break;
case R.id.jelly:effect=Effects.jelly;break;
case R.id.slidein:effect=Effects.slideIn;break;
case R.id.flip:effect=Effects.flip;break;
case R.id.slideOnTop:effect=Effects.slideOnTop;break;
case R.id.standard:effect=Effects.standard;break;
} // NiftyNotificationView.build(this,msg, effect,R.id.mLyout)
// .setIcon(R.drawable.lion) //You must call this method if you use ThumbSlider effect
// .show(); // You can configure like this
// The default Configuration cfg=new Configuration.Builder()
.setAnimDuration(700)
.setDispalyDuration(1500)
.setBackgroundColor("#FFBDC3C7")
.setTextColor("#9C27B0")
.setIconBackgroundColor("#42A5F5")
.setTextPadding(5) //dp
.setViewHeight(48) //dp
.setTextLines(2) //You had better use setViewHeight and setTextLines together
.setTextGravity(Gravity.CENTER) //only text def Gravity.CENTER,contain icon Gravity.CENTER_VERTICAL
.build();
//
NiftyNotificationView.build(this,msg, effect,R.id.mLyout,cfg)
.setIcon(R.drawable.lion) //remove this line ,only text
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//add your code
}
})
.show(); // show(boolean) allow duplicates or showSticky() sticky notification,you can call removeSticky() method close it
} }

生动有趣的动画Toast--第三方开源--NiftyNotification的更多相关文章

  1. 开源框架】Android之史上最全最简单最有用的第三方开源库收集整理,有助于快速开发

    [原][开源框架]Android之史上最全最简单最有用的第三方开源库收集整理,有助于快速开发,欢迎各位... 时间 2015-01-05 10:08:18 我是程序猿,我为自己代言 原文  http: ...

  2. iOS项目中常用的第三方开源库

    1.项目使用的第三方开源库 项目使用了CocoaPods(类似java中的maven)管理常用的第三方库,一些特殊的单独引用,下面介绍下比较好用的几个. (1)AFNetworking 目前比较推荐的 ...

  3. Android 第三方开源库收集整理(转)

    原文地址:http://blog.csdn.net/caoyouxing/article/details/42418591 Android开源库 自己一直很喜欢Android开发,就如博客签名一样,  ...

  4. 45.Android 第三方开源库收集整理(转)

    原文地址:http://blog.csdn.net/caoyouxing/article/details/42418591 Android开源库 自己一直很喜欢Android开发,就如博客签名一样,  ...

  5. 【开源框架】Android之史上最全最简单最有用的第三方开源库收集整理,有助于快速开发,欢迎各位网友补充完善

    链接地址:http://www.tuicool.com/articles/jyA3MrU 时间 2015-01-05 10:08:18  我是程序猿,我为自己代言 原文  http://blog.cs ...

  6. Android之史上最全最简单最有用的第三方开源库收集整理

    Android开源库 自己一直很喜欢Android开发,就如博客签名一样, 我是程序猿,我为自己代言 . 在摸索过程中,GitHub上搜集了很多很棒的Android第三方库,推荐给在苦苦寻找的开发者, ...

  7. iOS常用第三方开源框架和优秀开发者博客等

    博客收藏iOS开发过程好的开源框架.开源项目.Xcode工具插件.Mac软件.文章等,会不断更新维护,希望对你们有帮助.如果有推荐或者建议,请到此处提交推荐或者联系我. 该文档已提交GitHub,点击 ...

  8. Android第三方开源对话消息提示框:SweetAlertDialog(sweet-alert-dialog)

    Android第三方开源对话消息提示框:SweetAlertDialog(sweet-alert-dialog) Android第三方开源对话消息提示框:SweetAlertDialog(sweet- ...

  9. Android的SwipeToDismiss第三方开源框架模拟QQ对话列表侧滑删除,置顶,将头像图片圆形化处理。

      <Android SwipeToDismiss:左右滑动删除ListView条目Item> Android的SwipeToDismiss是github上一个第三方开源框架(github ...

随机推荐

  1. cat命令的作用

    1.显示文件内容,如more的功能. 使用方法: cat  filename. 注:cat,无论文件多长,一次性全部显示:more,一次只显示一个屏幕高度的内容. 2.创建文件,如touch功能. 使 ...

  2. XMLObject 简易xml格式接口数据生成和解析工具

    简单的请求封装,相当于封装了Book对象,但比Book对象参数更灵活 XMLObject xml = new XMLObject("book");xml.add("aut ...

  3. Failed to load IDE add in 'C:\Program Files\Delphi_2007\bin\Borland.Studio.Together.dll'.解决办法 转

    错误信息为: Failed to load IDE add in 'C:\Program Files\Delphi_2007\bin\Borland.Studio.Together.dll'.Exce ...

  4. Python中的字符串处理

    Python转义字符 在需要在字符中使用特殊字符时,python用反斜杠(\)转义字符.如下表: 转义字符 描述 \(在行尾时) 续行符 \\ 反斜杠符号 \' 单引号 \" 双引号 \a ...

  5. POJ 3164 Command Network 最小树形图模板

    最小树形图求的是有向图的最小生成树,跟无向图求最小生成树有很大的区别. 步骤大致如下: 1.求除了根节点以外每个节点的最小入边,记录前驱 2.判断除了根节点,是否每个节点都有入边,如果存在没有入边的点 ...

  6. Codeforces Round #198 (Div. 1) B,C 动态规划

    比赛时,开了大号去做,算了半天发现不会做A,囧.于是跑去看B,发现很水?于是很快敲完了,但是A不会,没敢交.于是去看C,一直找规律啊,后来总算调了出来,看了一下榜,发现还是算了吧,直接去睡觉了.第二天 ...

  7. 实现多个UIView之间切换的动画效果

    @interface RootViewController (){ UIView *view1; UIView *view2; int flag; } @end @implementation Roo ...

  8. tmux使用

    1.配置文件的使用 在~/.tmux.conf中添加: setw -g mouse-resize-pane on setw -g mouse-select-pane on setw -g mouse- ...

  9. Table of Contents - Redis

    Getting Started 安装配置环境 Redis 命令 Keys Strings Lists Hashs Sets Sorted Sets Transactions Connection Se ...

  10. 根据不同的浏览器对不同元素进行css调整

    <!if firefox> .element { top:4px; } <![endif]> <!if chrome> .element { top:6px; } ...