Android动画效果生动有趣的通知NiftyNotification(Android Toast替代品)
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替代品)的更多相关文章
- Android动画效果之自定义ViewGroup添加布局动画
前言: 前面几篇文章介绍了补间动画.逐帧动画.属性动画,大部分都是针对View来实现的动画,那么该如何为了一个ViewGroup添加动画呢?今天结合自定义ViewGroup来学习一下布局动画.本文将通 ...
- Android动画效果之Property Animation进阶(属性动画)
前言: 前面初步认识了Android的Property Animation(属性动画)Android动画效果之初识Property Animation(属性动画)(三),并且利用属性动画简单了补间动画 ...
- Android动画效果之初识Property Animation(属性动画)
前言: 前面两篇介绍了Android的Tween Animation(补间动画) Android动画效果之Tween Animation(补间动画).Frame Animation(逐帧动画)Andr ...
- Android动画效果之Frame Animation(逐帧动画)
前言: 上一篇介绍了Android的Tween Animation(补间动画) Android动画效果之Tween Animation(补间动画),今天来总结下Android的另外一种动画Frame ...
- Android动画效果之Tween Animation(补间动画)
前言: 最近公司项目下个版本迭代里面设计了很多动画效果,在以往的项目中开发中也会经常用到动画,所以在公司下个版本迭代开始之前,抽空总结一下Android动画.今天主要总结Tween Animation ...
- 200多种Android动画效果的强悍框架
admin 发布于2015-10-23 14:33 363/68015 [精品推荐]200多种Android动画效果的强悍框架,太全了,不看这个,再有动画的问题,不理你了^@^ 功能模块和技术方案 只 ...
- android 动画效果
动画资源 一.分类: (一).概要: 3.0以前,android支持两种动画模式,补间动画(tween animation),帧动画(frame animation),在android ...
- Android -- 动画效果收获(1)
加载选项菜单 MenuInflater inflater = getMenuInflater(); inflater.inflater(R.menu.menu,menu); An ...
- Android动画效果translate、scale、alpha、rotate详解
动画类型 Android的animation由四种类型组成 XML中 alpha 渐变透明度动画效果 scale 渐变尺寸伸缩动画效果 translate 画面转换位置移动动画效果 rotate 画面 ...
随机推荐
- iOS - Swift NSKeyedArchiver 数据归档
前言 public class NSKeyedArchiver : NSCoder public class NSKeyedUnarchiver : NSCoder 在 OC 语言中,归档是一个过程, ...
- SAP 关于标准成本、计划成本、目标成本、实际成本
SAP 关于标准成本.计划成本.目标成本.实际成本 <A style="MARGIN-RIGHT: 10px" target=_blank data-ext="{v ...
- Visual Studio 2012 RC 中RC表示什么意思
来自:http://zhidao.baidu.com/question/507233956.html Release Candidate 缩写为 RC ,经常用于计算机软件方面,表示软件的候选发布版. ...
- Java 多线程 (转)
http://www.ibm.com/developerworks/cn/java/j-thread/index.html http://www.ibm.com/developerworks/cn/j ...
- 08 Transactions
本章提要------------------------------------------事务的特性事务控制语句------------------------------------------事 ...
- json与jsonp应用及其他ajax数据交互方式
1.json是数据交换格式,使用实例如下: $.getJSON( '/manage/asset/asset_delByIds.action', { 'ids':id }, function(data) ...
- js 高程(三)学习感言(随时更新)
1.读第二遍了,感觉第一遍白读了. 2.现在还处于初学...
- SDL1.2到2.0的迁移指南(转)
里面有些单词不好翻译所以放在开头,以备查验. BLock Image Transfer, a computer graphics operation in which two bitmap patte ...
- Linux大文件分割split和合并cat使用方法
本文主要介绍linux下两个命令:split和cat.其中,相信大家都熟悉cat命令,一般用来查看一个文件的内容,但是它还其它的功能,比如这里要介绍的文件合并功能,它可把多个文件内容合并到一个文件中. ...
- 利用SecureCRT上传、下载文件(使用sz与rz命令),超实用!
利用SecureCRT上传.下载文件(使用sz与rz命令),超实用! 文章来源:http://blog.csdn.net/dongqinliuzi/article/details/39623169 借 ...