摘要 popwindow通过setAnimationStyle(int animationStyle)函数来设置动画效果 android:windowEnterAnimation表示进入窗口动画 android:windowExitAnimation表示窗口退出动画 在res/values/style.xml代码: ?xml version="1.0" encoding="utf-8"? resources style

popwindow通过setAnimationStyle(int animationStyle)函数来设置动画效果
android:windowEnterAnimation表示进入窗口动画
android:windowExitAnimation表示窗口退出动画

在res/values/style.xml代码:

  1. <?xml version="1.0"encoding="utf-8"?>
  2. <resources>
  3. <style name="PopupAnimation"parent="android:Animation"mce_bogus="1">
  4. <item name="android:windowEnterAnimation">@anim/popup_enter</item>
  5. <item name="android:windowExitAnimation">@anim/popup_exit</item>
  6. </style>
  7. </resources>

在res/anim/popup_enter.xml声明所需进入动画

  1. <?xml version="1.0"encoding="utf-8"?>
  2. <set xmlns:android="http://schemas.android.com/apk/res/android">
  3. <scale android:fromXScale="0.6"android:toXScale="1.0"
  4. android:fromYScale="0.6"android:toYScale="1.0"android:pivotX="50%"
  5. android:pivotY="50%"android:duration="1000"/>
  6. <alpha android:interpolator="@android:anim/decelerate_interpolator"
  7. android:fromAlpha="0.0"android:toAlpha="1.0"android:duration="1000"/>
  8. </set>

在res/anim/popup_exit.xml声明所需退出动画

  1. <?xml version="1.0"encoding="utf-8"?>
  2. <set xmlns:android="http://schemas.android.com/apk/res/android">
  3. <scale
  4. android:fromXScale="1.0"
  5. android:toXScale="0.5"
  6. android:fromYScale="1.0"
  7. android:toYScale="0.5"
  8. android:pivotX="50%"
  9. android:pivotY="50%"
  10. android:duration="500"/>
  11. <alpha
  12. android:interpolator="@android:anim/accelerate_interpolator"
  13. android:fromAlpha="1.0"
  14. android:toAlpha="0.0"
  15. android:duration="500"/>
  16. </set>

设置popwindow的位置及动画

popupWindow.setAnimationStyle(R.style.PopupAnimation);
popupWindow.showAtLocation(findViewById(R.id.parent), Gravity.CENTER| Gravity.CENTER, 0, 0);
popupWindow.update();

调用popupWindow.dismiss();语句。popwindow消失,自动调用消失动画popup_exit.xml

http://blog.csdn.net/heng615975867/article/details/8893655

setAnimationStyle实现的popwindow显示消失的动画效果的更多相关文章

  1. 使用jQuery 中的显示与隐藏动画效果实现折叠下拉菜单的收缩和展开,在页面的列表中有若干项,列表的每项中有一个二级列表,二级列表默认为隐藏状态。点击列表的项,切换二级列表的显示或隐藏状态

    查看本章节 查看作业目录 需求说明: 使用jQuery 中的显示与隐藏动画效果实现折叠下拉菜单的收缩和展开,在页面的列表中有若干项,列表的每项中有一个二级列表,二级列表默认为隐藏状态.点击列表的项,切 ...

  2. AngularJS中实现显示或隐藏动画效果的3种方式

    本篇体验在AngularJS中实现在"显示/隐藏"这2种状态切换间添加动画效果. 通过CSS方式实现显示/隐藏动画效果 思路: →npm install angular-anima ...

  3. android view控件的显示和隐藏动画效果

    // 显示动画 mShowAction = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO ...

  4. wpf image控件循环显示图片 以达到动画效果 问题及解决方案

    1>最初方案: 用wpf的image控件循环显示图片,达到动画效果,其实就是在后台代码动态改变Image.Source的值,关键代码: ; i < ; i++)//六百张图片 { Bitm ...

  5. iOS各种动画效果

    ios各种动画效果 最普通动画: //开始动画 [UIView beginAnimations:nil context:nil];  //设定动画持续时间 [UIView setAnimationDu ...

  6. 自定义UIView动画效果

    最普通动画: //开始动画 [UIView beginAnimations:nil context:nil]; //设定动画持续时间 [UIView setAnimationDuration:]; / ...

  7. 微信小程序(19)-- 从底部向上滑出的动画效果

    从底部向上滑出的动画效果: 用到了小程序的触摸事件bindtouchmove,以及创建一个annimation对象,完成动画操作之后使用animation这个对象的export()方法导出动画数据. ...

  8. 如何让popWindow显示在view上方

    看了bilibili的客户端搜索按钮,很喜欢大爱!自己也想做个类似的(相似度 10% 哈哈) popWin的出现退出动画也可以自己设定,用过其方法setAnimationStyle(R.style.x ...

  9. jQuery css3鼠标悬停图片显示遮罩层动画特效

    jQuery css3鼠标悬停图片显示遮罩层动画特效 效果体验:http://hovertree.com/texiao/jquery/39/ 效果图: 源码下载:http://hovertree.co ...

随机推荐

  1. BZOJ1725: [Usaco2006 Nov]Corn Fields牧场的安排

    1725: [Usaco2006 Nov]Corn Fields牧场的安排 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 400  Solved: 290 ...

  2. 【转】Android:控件Spinner实现下拉列表

    原文网址:http://www.cnblogs.com/tinyphp/p/3858920.html 在Web开发中,HTML提供了下拉列表的实现,就是使用<select>元素实现一个下拉 ...

  3. Android调用第三方应用

    Intent intent=new Intent(); //包名 包名+类名(全路径) intent.setClassName("com.qn.app.store", " ...

  4. awr报告基本操作

    1.查看当前的AWR保存策略.设置:快照间隔.保存时间. SQL> col SNAP_INTERVAL format a20    SQL> col RETENTION format a2 ...

  5. CSS 入门

    以下内容均来自 慕课网 CSS全称为"层叠样式表 (Cascading Style Sheets)",它主要是用于定义HTML内容在浏览器内的显示样式,如文字大小.颜色.字体加粗等 ...

  6. 自适应网页设计(Responsive Web Design)(转)

    作者: 阮一峰 出处:http://www.ruanyifeng.com/blog/2012/05/responsive_web_design.html 随着3G的普及,越来越多的人使用手机上网. 移 ...

  7. [Angular 2] Interpolation: check object exists

    In Angular2, sometime we use @Output to pass data to parent component, then parent may pass the data ...

  8. Oracle11g新特性之动态变量窥视

    1. 11g之前的绑定变量窥视     我们都知道,为了可以让SQL语句共享运行计划,oracle始终都是强调在进行应用系统的设计时,必须使用绑定变量,也就是用一个变量来取代原来出如今SQL语句里的字 ...

  9. openwrt sdk compile

    recently ,bought a router : tl-wr741n-v5 hd my aim : let the router dail in neetkeeper environment : ...

  10. redisi配置安装

    一.单机配置 http://www.codeceo.com/article/centos-redis-setup.html 二.测试安装情况 http://blog.sina.com.cn/s/blo ...