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代码即可

 package com.gitonway.lee.niftynotification;

 import android.app.Activity;
import android.os.Bundle;
import android.view.View;
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 = "今天天气不错,心情也很好啊 !"; 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("#FF444444")
// .setIconBackgroundColor("#FFFFFFFF")
// .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
} }

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:textColor="#FFFFFF"
android:gravity="center"
android:text="Nifty Modal Notification Effects" />
<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_below="@+id/title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="true"
> </RelativeLayout>
</RelativeLayout>

运行效果图:

Android动画效果生动有趣的通知NiftyNotification(Android Toast替代品)的更多相关文章

  1. Android动画效果之自定义ViewGroup添加布局动画

    前言: 前面几篇文章介绍了补间动画.逐帧动画.属性动画,大部分都是针对View来实现的动画,那么该如何为了一个ViewGroup添加动画呢?今天结合自定义ViewGroup来学习一下布局动画.本文将通 ...

  2. Android动画效果之Property Animation进阶(属性动画)

    前言: 前面初步认识了Android的Property Animation(属性动画)Android动画效果之初识Property Animation(属性动画)(三),并且利用属性动画简单了补间动画 ...

  3. Android动画效果之初识Property Animation(属性动画)

    前言: 前面两篇介绍了Android的Tween Animation(补间动画) Android动画效果之Tween Animation(补间动画).Frame Animation(逐帧动画)Andr ...

  4. Android动画效果之Frame Animation(逐帧动画)

    前言: 上一篇介绍了Android的Tween Animation(补间动画) Android动画效果之Tween Animation(补间动画),今天来总结下Android的另外一种动画Frame ...

  5. Android动画效果之Tween Animation(补间动画)

    前言: 最近公司项目下个版本迭代里面设计了很多动画效果,在以往的项目中开发中也会经常用到动画,所以在公司下个版本迭代开始之前,抽空总结一下Android动画.今天主要总结Tween Animation ...

  6. 200多种Android动画效果的强悍框架

    admin 发布于2015-10-23 14:33 363/68015 [精品推荐]200多种Android动画效果的强悍框架,太全了,不看这个,再有动画的问题,不理你了^@^ 功能模块和技术方案 只 ...

  7. android 动画效果

    动画资源 一.分类: (一).概要:         3.0以前,android支持两种动画模式,补间动画(tween animation),帧动画(frame animation),在android ...

  8. Android -- 动画效果收获(1)

    加载选项菜单         MenuInflater inflater = getMenuInflater();    inflater.inflater(R.menu.menu,menu); An ...

  9. Android动画效果translate、scale、alpha、rotate详解

    动画类型 Android的animation由四种类型组成 XML中 alpha 渐变透明度动画效果 scale 渐变尺寸伸缩动画效果 translate 画面转换位置移动动画效果 rotate 画面 ...

随机推荐

  1. JS 和 Java 中URL特殊字符编码方式

    前几天遇到url特殊字符编码的问题,在这里整理一下: JavaScript 1.  编码 escape(String) 其中某些字符被替换成了十六进制的转义序列. 解码 unescape(String ...

  2. iOS开发之引用百度地图SDK(一)-----------SDK开发指南

    (void)viewWillAppear:(BOOL)animated { [_mapView viewWillAppear]; _mapView.delegate = self; // 此处记得不用 ...

  3. spring的初始化bean,销毁bean之前的操作详解

    我所知道的在spring初始化bean,销毁bean之前的操作有三种方式: 第一种:通过@PostConstruct 和 @PreDestroy 方法 实现初始化和销毁bean之前进行的操作 第二种是 ...

  4. VirtualBox的网络配置,Host Only+NAT方式 (zhuan)

    http://blog.csdn.net/xinghun_4/article/details/7969894 ***************************************** 其实网 ...

  5. C#_微信支付V3

    基础问题先排除: 确保 商户功能 审核通过,会有官方邮件 支付授权目录(注意看文档,大小写关系很大 点击支付按钮,提示“access_denied” 网上有很多关于此问题的解决) 点击支付按钮,提示“ ...

  6. Oracle数据库和DB2数据库分页SQL的区别举例

    --------------------------ORACLE数据库分页SQL举例------------------------------------------------ SELECT * ...

  7. 启动一个新的activity并携带数据,返回数据给上一个activity

    一.在启动一个新的activity的时候可以通过Intent携带数据,通过Intent.putExtra()方法通过键值对的形势装入数据.在新启动的activity中通过           getI ...

  8. 如何从NFS文件系统启动

    笔记,备忘! 步骤: 1.设置好NFS服务器 2.修改uboot启动参数bootarg setenv bootargs console=ttySAC0 root=/dev/nfs nfsroot=19 ...

  9. OneProxy FAQ 之proxy-user-list

    OneProxy为了实现拆库拆表,必须有能力管理多个主从集群. 启动脚本截取如下: ################################################# --proxy- ...

  10. android内存泄露小谈

    在做android的时候,用的语言大部分情况下都是java.以前最开始做的是编译器开发, 大部分情况都是用c语言和x86与arm架构的汇编,后来接触到ios用的是OC.对比之下, 感觉还是java用起 ...