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 画面 ...
随机推荐
- 老笔记本_Win7_U盘_ReadyBoost
老笔记本 Win7 U盘 ReadyBoost 值得尝试
- php提示:Call to undefined function curl_init
我要利用curl函数进行数据采集时发现提示Call to undefined function curl_init错误了,后来从官网了解到因为curl默认不是php开启的函数,我们需要手工打开哦,下面 ...
- 自定义获取焦点的TextView
自定义控件编写流程 创建一个默认就能获取焦点的TextView 1.创建一个类继承至TextView,FocusTextView 2.重写其构造方法 //使用在通过java代码创建控件 public ...
- 【Todo】Nginx架构学习
要进行Web服务,绕不开的就是Nginx.这已经是大型网站的标配.对Nginx进行一定程度的深入学习. http://www.ituring.com.cn/article/4436 http://bl ...
- Jump Game II
Description: Given an array of non-negative integers, you are initially positioned at the first inde ...
- TCP/IP,Http,Socket,XMPP的区别
大学学习网络基础的时候老师讲过,网络由下往上分为物理层.数据链路层.网络层.传输层.会话层.表示层和应用层.通过初步的了解,我知道IP协议对应于网络层,TCP协议对应于传输层,而HTTP协议对应于应用 ...
- mac homebrew PHP
启动PHP p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px "Andale Mono"; color: #29f914; ...
- Spring集成JPA提示Not an managed type
在做Spring与JPA集成时,出现问题如下: Caused by: java.lang.IllegalArgumentException: Not an managed type: class co ...
- Yum常用命令及Yum中文手册
转自:http://blog.csdn.net/huangbiao86/article/details/6646471 Yum配置文件位于/etc/yum.conf和/etc/yum.repos.d/ ...
- hiho_1079_离散化
题目 在长度为L的宣传栏上张贴N张海报,将宣传栏分为L个长度为1的单位,海报长度为整数,且高度和宣传栏相同,左右边界和宣传栏单位之间缝隙重合(即海报总是跨越整数个单位).后贴的海报可能会覆盖之前贴的海 ...