Android 按钮动画:文本已设置动画,但背景形状是静态的
我有一个按钮动画,它被定义为从1.0缩放到1.1再缩放回来。按钮(“下一步”)的文本可上下缩放,但按钮大小不变。Android 按钮动画:文本已设置动画,但背景形状是静态的,android,android-animation,Android,Android Animation,我有一个按钮动画,它被定义为从1.0缩放到1.1再缩放回来。按钮(“下一步”)的文本可上下缩放,但按钮大小不变。 1.这是预期的行为吗? 2.当它重新启动动画时会有一个抖动。我假设这是在loadAnimation()调用中发生的。有没有一种方法可以做到无缝连接 public void startAnimation() { final View nextButtonView = fragmentActivity.findViewById(R.id.game2NextButton)
1.这是预期的行为吗?
2.当它重新启动动画时会有一个抖动。我假设这是在loadAnimation()调用中发生的。有没有一种方法可以做到无缝连接
public void startAnimation() {
final View nextButtonView = fragmentActivity.findViewById(R.id.game2NextButton);
nextButtonView.setVisibility(View.VISIBLE);
Animation anim = AnimationUtils.loadAnimation(fragmentActivity, R.anim.scale_button);
anim.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationEnd(Animation arg0) {
Animation anim = AnimationUtils.loadAnimation(fragmentActivity, R.anim.scale_button);
anim.setAnimationListener(this);
nextButtonView.startAnimation(anim);
}
@Override
public void onAnimationRepeat(Animation arg0) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationStart(Animation arg0) {
// TODO Auto-generated method stub
}
});
nextButtonView.startAnimation(anim);
}
scale_button.xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<scale
android:duration="1000"
android:fillBefore="false"
android:fillAfter="false"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="1.1"
android:toYScale="1.1" />
<set android:interpolator="@android:anim/decelerate_interpolator" >
<scale
android:duration="1000"
android:fillBefore="false"
android:fillAfter="false"
android:fromXScale="1.1"
android:fromYScale="1.1"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="1000"
android:toXScale="1.0"
android:toYScale="1.0" />
</set>
</set>
android:repeatCount=“infinite”
您还可以使用此选项获得更无缝的结果:
android:repeatMode="reverse"
我希望这有帮助
android:repeatCount=“infinite”
您还可以使用此选项获得更无缝的结果:
android:repeatMode="reverse"
我希望这有帮助
android:repeatCount=“infinite”
您还可以使用此选项获得更无缝的结果:
android:repeatMode="reverse"
我希望这有帮助
android:repeatCount=“infinite”
您还可以使用此选项获得更无缝的结果:
android:repeatMode="reverse"
我希望这能有所帮助。我以前试过android:repeatCount=“infinite”。如果我把它放在第一个
,那么只有动画的前半部分会重复。如果我把它放在第二个
,只有动画的后半部分会重复。您能建议如何使用android:repeatCount=“infinite”`以便它们作为一个组重复吗?只需在animationEnd()上从动画侦听器中删除动画,然后在xml中添加android:repeatCount=“infinite”语句。它将无缝地增长和收缩,无限期。我以前曾尝试过android:repeatCount=“infinite”
。如果我把它放在第一个,那么只有动画的前半部分会重复。如果我把它放在第二个
,只有动画的后半部分会重复。您能建议如何使用android:repeatCount=“infinite”`以便它们作为一个组重复吗?只需在animationEnd()上从动画侦听器中删除动画,然后在xml中添加android:repeatCount=“infinite”语句。它将无缝地增长和收缩,无限期。我以前曾尝试过android:repeatCount=“infinite”
。如果我把它放在第一个,那么只有动画的前半部分会重复。如果我把它放在第二个
,只有动画的后半部分会重复。您能建议如何使用android:repeatCount=“infinite”`以便它们作为一个组重复吗?只需在animationEnd()上从动画侦听器中删除动画,然后在xml中添加android:repeatCount=“infinite”语句。它将无缝地增长和收缩,无限期。我以前曾尝试过android:repeatCount=“infinite”
。如果我把它放在第一个,那么只有动画的前半部分会重复。如果我把它放在第二个
,只有动画的后半部分会重复。您能建议如何使用android:repeatCount=“infinite”`以便它们作为一个组重复吗?只需在animationEnd()上从动画侦听器中删除动画,然后在xml中添加android:repeatCount=“infinite”语句。它将无缝无限地增长和收缩
android:repeatMode="reverse"