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();
  • 相关阅读:
    lua编程之协程介绍
    lua编程之元表与元方法
    设计模式系列之单例模式
    设计模式系列之生成器模式
    设计模式系列之抽象工厂模式
    设计模式系列之原型模式
    设计模式系列之工厂模式
    stl源码分析之hash table
    2018/2019款 MacBookPro 接口失灵的原因及解决方案
    test
  • 原文地址:https://www.cnblogs.com/wangziqiang/p/4184306.html
Copyright © 2011-2022 走看看