首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TextSwitcher和ImageSwitcher的链接动画

TextSwitcher和ImageSwitcher的链接动画
EN

Stack Overflow用户
提问于 2016-07-02 06:56:22
回答 1查看 286关注 0票数 0

我有一个带有TextSwitcher和ImageSwitcher对象的android studio项目,它们已经设置好了,并且(同时)可以完美地工作。问题是,我希望首先执行TextSwitcher的动画,然后是ImageSwitcher的动画(在TextSwitcher动画结束之后)。我尝试将AnimationListener添加到TextSwitcher中,并在AnimationListener的“onAnimationEnd”方法中更改ImageSwitcher的图像,但不起作用。

有谁有什么想法吗?任何帮助都将不胜感激!

编辑:为了让动画监听程序工作,下面是代码片段:

代码语言:javascript
复制
   private void loadPosts() {
        Post post = posts.get(currentPost);
        //..
        Animation outAnimation = AnimationUtils.loadAnimation(this, R.anim.fade_out);
        outAnimation.setAnimationListener(new NextPostAnimation(post));
        textSwitcher.setOutAnimation(outAnimation);
        textSwitcher.setText("some text");

    }

    private class NextPostAnimation implements Animation.AnimationListener {
        Post post;

        NextPostAnimation (Post post) {
            super();
            this.post = post;
        }
        @Override
        public void onAnimationStart(Animation animation) {
             // TODO Auto-generated method stub
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            imageSwitcher1.setImageDrawable(new BitmapDrawable(getResources(), post.image1));
        }
    }

有没有一种更短的方法来链接对象动画?

EN

回答 1

Stack Overflow用户

发布于 2016-07-02 07:04:57

你应该把第二个动画放在第一个动画回调中。下面是工作代码。

代码语言:javascript
复制
$(function(){
	$('.textSwitcher').show(1000, function(){
    	$('.imageSwitcher').show(1000);
    });
})
代码语言:javascript
复制
.textSwitcher, .imageSwitcher {
    width: 100px;
    height: 100px;
    display: none;
}
.textSwitcher {
    background: red;
}

.imageSwitcher {
    background: blue;    
}
代码语言:javascript
复制
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="textSwitcher"></div>
<div class="imageSwitcher"></div>

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38154814

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档