问题描述
所以,我有一个编程方式添加PopupWindow它看起来是这样的:
So, I have a programmatically added PopupWindow which looks like this:
dialog = new PopupWindow(context);
dialog.setContentView(ll);
dialog.showAtLocation(view, Gravity.LEFT | Gravity.TOP, -70, 0);
dialog.setWidth(w);
dialog.setHeight(h - 50);
dialog.setOutsideTouchable(true);
//The dialog.update is somewhere else, I didn't bother adding it too as it is not important for this matter (I guess)
我想要做的是有某种动画效果,像它弹出从一按钮,我preSS这样的弹出窗口。 (这只是一个例子,我只是想任何形式的动画)。
What I want to do is to have some sort of animation effect , like it pops right from the button I press so the popup appears. (this is just an example, I just want any sort of animation).
文件将确定过,只要它不是基于XML(我发现那些已经 - 不是真的帮助我)。
Documentation would be ok too, as long as it is not XML based (I found those already -not really helping me).
如果还需要其他细节,我会发表评论或编辑的问题。
If other details are needed ,I will comment or edit the question.
推荐答案
所以,我设法解决这个问题。
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.
这篇关于以编程方式添加动画效果为(以编程方式添加)popupWindow在安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!