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();
  • 相关阅读:
    在source insight中阅读Python代码
    修改linux命令行提示符
    gcc链接程序时出现undefined reference to""错误
    [转]init.d解析
    [转]Linux中find常见用法示例
    Linux的网卡由eth0变成了eth1,如何修复?
    测试使用Windows Live Writer
    黑盒测试
    白盒测试技术(二)
    白盒测试技术(一)
  • 原文地址:https://www.cnblogs.com/wangziqiang/p/4184306.html
Copyright © 2011-2022 走看看