Android的补间动画快速闪烁并不起作用 [英] Android tween animation blinks fast and doesn't work
问题描述
我试图让一个TextView规模和淡出。我的TextView是纳入我的活动与
布局的布局文件中 <包括机器人:ID =@ + ID / HUD布局=@布局/ HUD机器人:layout_alignParentBottom =真/>
现在,我可以从Java code这样在应用规模的动画
TextView的乘数=(的TextView)findViewById(R.id.hudMultiplier);
ScaleAnimation S =新ScaleAnimation(1.0F,3.0F,1.0F,3.0F);
s.setDuration(5000);
multiplier.startAnimation(多个);
和它工作得很好,但我想从一个XML文件,动画(和一堆别人的)。所以我做了这个文件:
<?XML版本=1.0编码=UTF-8&GT?;
<集
的xmlns:机器人=http://shemas.android.com/apk/res/android
机器人:shareInterpolator =假>
<规模
机器人:pivotX =50%
机器人:pivotY =100%
机器人:fromXScale =1.0
机器人:fromYScale =1.0
机器人:toXScale =10.0
机器人:toYScale =10.0
机器人:时间=5000
机器人:插值=@机器人:动画/ accelerate_decelerate_interpolator
/>
<阿尔法
机器人:fromAlpha =1.0
机器人:toAlpha =0.1
机器人:时间=2000
机器人:startOffset =2000>
< /阿尔法>
< /集>
我想这个code应用动画:
TextView的乘数=(的TextView)findViewById(R.id.hudMultiplier);
AnimationSet一个=(AnimationSet)AnimationUtils.loadAnimation(getApplicationContext(),R.anim.multiplier);
multiplier.startAnimation(一);
现在什么情况是TextView的闪烁一秒钟的一小部分并没有什么实际发生的。
我试过:
- 删除奥飞动漫 - 没有变化
- 删除起始位置的偏移 - 没有变化
- 从Android文档更改与一个动画 - 没有变化
- 变化AnimationSet动画 - 没有变化
- 变化getApplicationContext()这一点,MyActivity.this - 无变化
- 变化getApplicationContext()为null - 杀死应用程序
我是什么失踪?
该项目的目标是Android 1.6的,我在2.3模拟器测试。
这似乎有所作为,我反正!
更改shemas在设置元素的模式。
<?XML版本=1.0编码=UTF-8&GT?;
<集
的xmlns:机器人=http://shemas.android.com/apk/res/android
机器人:shareInterpolator =假>
I am trying to make a TextView scale and fade out. My TextView is inside a layout file that is included into my activity's layout with
<include android:id="@+id/hud" layout="@layout/hud" android:layout_alignParentBottom="true"/>
Now, I can apply a scale animation from within the Java code like this:
TextView multiplier = (TextView)findViewById(R.id.hudMultiplier);
ScaleAnimation s = new ScaleAnimation(1.0f, 3.0f, 1.0f,3.0f);
s.setDuration(5000);
multiplier.startAnimation(s);
And it works nicely, but I want that animation (and a bunch of others) from an xml file. So I made this file:
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://shemas.android.com/apk/res/android"
android:shareInterpolator="false">
<scale
android:pivotX="50%"
android:pivotY="100%"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:toXScale="10.0"
android:toYScale="10.0"
android:duration="5000"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
/>
<alpha
android:fromAlpha="1.0"
android:toAlpha="0.1"
android:duration="2000"
android:startOffset="2000">
</alpha>
</set>
I am trying to apply the animation with this code:
TextView multiplier = (TextView)findViewById(R.id.hudMultiplier);
AnimationSet an = (AnimationSet) AnimationUtils.loadAnimation(getApplicationContext(), R.anim.multiplier);
multiplier.startAnimation(an);
What happens now is that the TextView blinks for a fraction of a second and nothing actually happens.
I've tried:
- removing the alpha animation - no change
- removing the start offset - no change
- change the animation with one from the android documentation - no change
- change AnimationSet to Animation - no change
- change getApplicationContext() to this, MyActivity.this - no change
- change getApplicationContext() to null - kills the application
What am I missing?
The project is targeted at Android 1.6 and I'm testing in a 2.3 emulator.
This seems to make a difference, for me anyway!
Change shemas to schemas in the Set element.
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://shemas.android.com/apk/res/android"
android:shareInterpolator="false">
这篇关于Android的补间动画快速闪烁并不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!