zoukankan      html  css  js  c++  java
  • Android UI(继承控件)--PopupWindow设置动画

    1,在res/anim 下定义popupwindow 出现和消失的动画

    ①出现的动画popupwindow_show.xml

    1 <?xml version="1.0" encoding="utf-8"?>
    2 <alpha xmlns:android="http://schemas.android.com/apk/res/android"
    3     android:duration="1000"
    4     android:fromAlpha="0.0"
    5     android:fillAfter="true"
    6     android:interpolator="@android:anim/accelerate_decelerate_interpolator"
    7     android:toAlpha="1.0" >
    8 </alpha>

    ②消失的动画popupwindow_dismiss.xml

    1 <?xml version="1.0" encoding="utf-8"?>
    2 <alpha xmlns:android="http://schemas.android.com/apk/res/android"
    3     android:duration="1000"
    4     android:fromAlpha="1.0"
    5     android:fillAfter="true"
    6     android:interpolator="@android:anim/accelerate_decelerate_interpolator"
    7     android:toAlpha="0.0" >
    9 </alpha>

    2,popupwindow的动画是通过方法setAnimationStyle(R.style.popupwindow_anim_style);设置的。

    所以在res/values 下的styles.xml 中 添加

    1 <style name="popupwindow_anim_style">
    2         <item name="android:windowEnterAnimation">@anim/popupwindow_show</item>
    3         <item name="android:windowExitAnimation">@anim/popupwindow_dismiss</item>
    4 </style>

    3,应用到代码中

    mPopupWindow.setAnimationStyle(R.style.popupwindow_anim_style);
    mPopupWindow.update();
  • 相关阅读:
    快速排序算法
    HTTP中的重定向和请求转发的区别
    单链表的逆置(头插法和就地逆置)
    水仙花数学习
    构建n位元的格雷码
    算法学习day01 栈和队列
    数据结构学习总结 线性表之双向链表
    设计模式
    Nginx 初步认识
    数据结构学习总结(2) 线性表之单链表
  • 原文地址:https://www.cnblogs.com/wangziqiang/p/4184306.html
Copyright © 2011-2022 走看看