码迷,mamicode.com
首页 > Windows程序 > 详细

PopupWindow添加动画效果

时间:2014-07-06 13:23:38      阅读:268      评论:0      收藏:0      [点我收藏+]

标签:android   style   blog   http   color   文件   

1.定义PopupWindow弹出与消失的两个动画文件,放在anim文件夹下

popup_enter.xml

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

popup_exit.xml

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

2.styles.xml文件中注册这两个动画效果

<resources>
    <style name="popupAnimation">
        <item name="android:windowEnterAnimation">@anim/popup_enter</item>
        <item name="android:windowExitAnimation">@anim/popup_exit</item>
    </style>
</resources>

3.为创建的PopopWindow添加动画

inflater = getLayoutInflater();
layout = inflater.inflate(R.layout.menu, null);
menu = new PopupWindow(layout, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
menu.setAnimationStyle(R.style.popupAnimation);//添加动画

 

PopupWindow添加动画效果,布布扣,bubuko.com

PopupWindow添加动画效果

标签:android   style   blog   http   color   文件   

原文地址:http://www.cnblogs.com/jsczljh/p/3825793.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!