摘要 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. SolrCloud 5.2.1 installation and configuration

    虽然不是很有技术含量的事情,主要依靠的是阅读能力,然而知识的东西还是记录一下,以备后继待查. 环境相关 1. Server:h1,h2,h3 2. OS RHEL 6.2 3. Zookeeper 3 ...

  2. 从windows server 2003中学到的事儿

    2003让我学会了几件事儿, 第一.自己会装系统了. 第二.知道很多选项是可以自己进行设置的.这点很重要,本来xp用得很习惯,然后很多都理所当然得认为,就应该是那个样子,可是,并不是的. 在2003不 ...

  3. HDU_2052——画矩形

    Problem Description Give you the width and height of the rectangle,darw it.   Input Input contains a ...

  4. HDU_2035——求A^B的最后三位数

    Problem Description 求A^B的最后三位数表示的整数.说明:A^B的含义是“A的B次方”   Input 输入数据包含多个测试实例,每个实例占一行,由两个正整数A和B组成(1< ...

  5. HDU4452 Running Rabbits

    涉及知识点: 1. direction数组. 2. 一一映射(哈希). Running Rabbits Time Limit: 2000/1000 MS (Java/Others)    Memory ...

  6. java--对象比较器

    在实际的项目中,经常会遇到排序问题,对于基本数据类型java支持Arrays.sort()和Collection.sort()对集合进行排序,但是对用户自定义类型排序呢?java给我们提供了两种解决方 ...

  7. Django 内置分页--Paginator类

    官方文档 http://python.usyiyi.cn/django/topics/pagination.html 前端方法 http://www.tuicool.com/articles/RniU ...

  8. IT江湖

    我喜欢看武侠电影,尤其的70-80年代的邵氏电影,在这个期间,邵氏公司将金庸和古老很多小说都改拍成了电影,可以说,看这些电影是一种享受,真的! 对于现实中的IT世界,也像是一个江湖,当你掌握了一些技能 ...

  9. 带有中文的url和NSString中文的转换

    NSString *url = @"http://tw.news.yahoo.com/麵包魂東京吸睛-粉絲包圍導演-061222049.html"; NSLog(@"ur ...

  10. java Date获取 年月日时分秒

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3 ...