为PopupWindow设置动画

来源:互联网 发布:js input 变成 select 编辑:程序博客网 时间:2024/05/02 04:22

step1: 在res目录下创建anim文件夹,因为我们的animation动画的xml实现都是在anim文件夹下的

step2: 创建载入动画:

<span style="font-size:18px;"><?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android"    android:shareInterpolator="false"> <translate<span style="white-space:pre"><!-- 平移动画 --></span>        android:fromYDelta="100%p"        android:toYDelta="0"         android:duration="500"        /> <alpha<span style="white-space:pre"><!-- 渐变透明度 --></span>        android:fromAlpha="0.7"        android:toAlpha="1.0"         android:duration="300"        /> </set></span>

step3:创建消失动画:

<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android"    android:shareInterpolator="false"> <translate        android:fromYDelta="0"        android:toYDelta="100%p"         android:duration="3000"        /> <alpha        android:fromAlpha="1.0"        android:toAlpha="0.5"         android:duration="2000"        /> </set>

step4:创建style:

<span style="font-size:18px;"><style name="animation">        <item name="android:windowEnterAnimation">@anim/enter</item>     <item name="android:windowExitAnimation">@anim/out</item>     </style></span>


最后一步只需要在我们的代码中添上popupWindow.setAnimationStyle(R.style.animation);  即可,也就是为这个popupWindow设置一下动画风格即可完工~~~


效果图:


因为之前是用GBK编码,现在是UTF-8,懒得换了,就这样了,,,,PopupWindow的子布局是用GridView实现的,具体用法等同ListView



更多的动画就靠大家去随意发挥喽!!!

reference:http://blog.csdn.net/bob1993_dev/article/details/43684209

0 0
原创粉丝点击