生动有趣的动画Toast--第三方开源--NiftyNotification

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的更多相关文章
- 开源框架】Android之史上最全最简单最有用的第三方开源库收集整理,有助于快速开发
[原][开源框架]Android之史上最全最简单最有用的第三方开源库收集整理,有助于快速开发,欢迎各位... 时间 2015-01-05 10:08:18 我是程序猿,我为自己代言 原文 http: ...
- iOS项目中常用的第三方开源库
1.项目使用的第三方开源库 项目使用了CocoaPods(类似java中的maven)管理常用的第三方库,一些特殊的单独引用,下面介绍下比较好用的几个. (1)AFNetworking 目前比较推荐的 ...
- Android 第三方开源库收集整理(转)
原文地址:http://blog.csdn.net/caoyouxing/article/details/42418591 Android开源库 自己一直很喜欢Android开发,就如博客签名一样, ...
- 45.Android 第三方开源库收集整理(转)
原文地址:http://blog.csdn.net/caoyouxing/article/details/42418591 Android开源库 自己一直很喜欢Android开发,就如博客签名一样, ...
- 【开源框架】Android之史上最全最简单最有用的第三方开源库收集整理,有助于快速开发,欢迎各位网友补充完善
链接地址:http://www.tuicool.com/articles/jyA3MrU 时间 2015-01-05 10:08:18 我是程序猿,我为自己代言 原文 http://blog.cs ...
- Android之史上最全最简单最有用的第三方开源库收集整理
Android开源库 自己一直很喜欢Android开发,就如博客签名一样, 我是程序猿,我为自己代言 . 在摸索过程中,GitHub上搜集了很多很棒的Android第三方库,推荐给在苦苦寻找的开发者, ...
- iOS常用第三方开源框架和优秀开发者博客等
博客收藏iOS开发过程好的开源框架.开源项目.Xcode工具插件.Mac软件.文章等,会不断更新维护,希望对你们有帮助.如果有推荐或者建议,请到此处提交推荐或者联系我. 该文档已提交GitHub,点击 ...
- Android第三方开源对话消息提示框:SweetAlertDialog(sweet-alert-dialog)
Android第三方开源对话消息提示框:SweetAlertDialog(sweet-alert-dialog) Android第三方开源对话消息提示框:SweetAlertDialog(sweet- ...
- Android的SwipeToDismiss第三方开源框架模拟QQ对话列表侧滑删除,置顶,将头像图片圆形化处理。
<Android SwipeToDismiss:左右滑动删除ListView条目Item> Android的SwipeToDismiss是github上一个第三方开源框架(github ...
随机推荐
- [Arduino] 逗号分隔文本到数组的两种方法
以下是今日练习通过逗号来分割字符数组/字符串的2个例子和方法" 1.通过indexOf函数 /* *Splitsplit sketch *split a comma-separated st ...
- Android 高级UI设计笔记12:ImageSwitcher图片切换器
1. ImageSwitcher ImageSwitcher是Android中控制图片展示效果的一个控件,如:幻灯片效果...,颇有感觉啊.做相册一绝 2. 重要方法 setImageURI(Uri ...
- 【Android Api 翻译4】android api 完整翻译之Contacts Provider (学习安卓必知的api,中英文对照)
Contacts Provider 电话簿(注:联系人,联络人.通信录)提供者 ------------------------------- QUICKVIEW 快速概览 * Android's r ...
- MVC4 Forms 验证,部署到Hyper-v上.FormsAuthentication.SetAuthCookie无效的问题
这是IE10的一个bug或者说是asp.net4的一个Bug,在IE10里更改了http头,这样导致asp.net4认为客户端没有启用cookie,会导致验证失败.简单的解决方法是,在网站根目录,新增 ...
- tornado 杂记
一.建立一个简单的 hello world 网页 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 import tornado.iolo ...
- 转: https 单向双向认证说明_数字证书, 数字签名, SSL(TLS) , SASL
转自: http://www.cnblogs.com/mailingfeng/archive/2012/07/18/2597392.html 因为项目中要用到TLS + SASL 来做安全认证层. 所 ...
- 添加iPhone设备的udid之后,重新生成开发证书(Development)
选择Provisioning profiles-Development-添加 ,如图:
- 1027 姓名与ID[二分图匹配(匈牙利)]
1027 姓名与ID 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 大师 Master 题解 查看运行结果 题目描述 Description 有N个人,各自有一 ...
- swift(一)
var floatNum:Float = 10.2 //浮点型 var double:Double = 10.3333 //双精度浮点型 var isSuccess:Bool = true //fal ...
- 北京时间28号0点以后Scott Hanselman同志台宣布dotnet core 1.0 rtm
今日占住微信号头条的好消息<终于来了!微软.Net Core 1.0下载放出>.本人立马跑到官网http://dot.net看了一下,仍然是.net core 1.0 Preview 1版 ...