PopupWindow添加动画效果

2020-12-13 03:58

阅读:520

标签: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_enteritem>
        item name="android:windowExitAnimation">@anim/popup_exititem>
    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添加动画效果,搜素材,soscw.com

PopupWindow添加动画效果

标签:android   style   blog   http   color   文件   

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


评论


亲,登录后才可以留言!