动画渐变闪烁 - Android电子 [英] Fade animation blinks - Android

查看:576
本文介绍了动画渐变闪烁 - Android电子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想成立2的布局 - 我想要一个布局滑动起来,而当它完成另一个布局应该淡入

I'm trying to set up 2 layouts - I want one layout to slide up, and when it's finished another layout should fade in.

我设法得到它的工作,但在这两个动画和第一个布局的最后闪烁一次。
我该如何解决呢?

I've managed to get it working, but at the end of the two animation and first layout blinks once. How can I solve it?

这里的code(第一个布局被命名为titleLay,第二个叫registerLayout) -

Here's the code(first layout is named titleLay and the second one is called registerLayout)-

final TranslateAnimation slide = new TranslateAnimation(0, 0, 0,-100 ); 
slide.setDuration(500); 
slide.setFillAfter(true); 
slide.setAnimationListener(new AnimationListener() {

@Override
public void onAnimationStart(Animation animation) {


}

@Override
public void onAnimationRepeat(Animation animation) {

}

@Override
public void onAnimationEnd(Animation animation) {
    RelativeLayout registerLayout  = (RelativeLayout) findViewById(R.id.registerLay);
    Animation fadeInAnimation = AnimationUtils.loadAnimation(con, R.anim.fade_in_anim);
    registerLayout.startAnimation(fadeInAnimation);
    registerLayout.setVisibility(View.VISIBLE);
}
});

titleLay.startAnimation(slide);

这就是的XML code中的 R.anim.fade_in_anim -

<?xml version="1.0" encoding="UTF-8"?>
 <set xmlns:android="http://schemas.android.com/apk/res/android">
    <alpha android:fromAlpha="0.0" android:toAlpha="1.0" 
     android:interpolator="@android:anim/accelerate_interpolator" 
    android:duration="500"/>
</set>

编辑:如果我使用其他类型的动画(淡出,幻灯片等...),它工作正常,无弹

If I use other types of animations(fade out, slide etc...) it works fine, without flicking.

谢谢!

推荐答案

而不是设置视图的可见性,尽量使用 setAlpha 功能。

Instead of setting the view's visibility, try to use the setAlpha function.

registerLayout.setAlpha(0f); //invisible

registerLayout.setAlpha(1f); //visible

这篇关于动画渐变闪烁 - Android电子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆