且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

以编程方式添加动画效果为(以编程方式添加)popupWindow在安卓

更新时间:2023-11-30 16:45:10

所以,我设法解决这个问题。

So, I managed to deal with this problem.

有三个简单的步骤来实现的动画效果。

There are three simple steps to achieve the animation effect.

第一:     做两个XMLS属于animation.In这里下了我的情况是这两个。   animation_on.xml

First: Make two XMLs that are the animation.In my case were those two following down here. animation_on.xml

 <scale xmlns:android="http://schemas.android.com/apk/res/android"
  android:toXScale="1.0"              
  android:fromXScale="0.0"            

  android:toYScale="1.0"
  android:fromYScale="0.0"

  android:pivotX="0%"
  android:pivotY="50%"


  android:startOffset="100"
  android:duration="300" />

animation_off.xml

animation_off.xml

   <scale xmlns:android="http://schemas.android.com/apk/res/android"
   android:toXScale="0.0"              
   android:fromXScale="1.0"            

   android:toYScale="0.0"
   android:fromYScale="1.0"

   android:pivotX="0%"
   android:pivotY="50%"


   android:startOffset="100"
   android:duration="300" />

二:

<style name="animationName" parent="android:Animation">
    <item name="android:windowEnterAnimation">@anim/animation_on</item>
    <item name="android:windowExitAnimation">@anim/animation_off</item>
</style>

三:

 dialog = new PopupWindow(context);
 // ....other code, whatever you want to do with your popupWindow (named dialog in our case here)
 dialog.setAnimationStyle(R.style.animationName);

如果有人需要帮助,这一点,离开comment.I会回答那么快,我可以。

If anyone needs help with this, leave comment.I will answer as fast as I can.