首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在每次查看器更改上显示动画

在每次查看器更改上显示动画
EN

Stack Overflow用户
提问于 2015-06-12 07:07:33
回答 2查看 322关注 0票数 1

我想显示动画的每一个内容的布局充气机。下面是我正在使用的代码,但问题是动画只显示在视图寻呼机的第一页上。

到目前为止,我所理解的是,所有页面内容上的动画都加载到了0位置,但我可能错了。

代码语言:javascript
复制
@Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            View v = null;
            if (position == 0) {

                Home.rel_footer.setVisibility(View.VISIBLE);

                v = inflater.inflate(R.layout.reward_points_circles, container,
                        false);

                YoYo.with(Techniques.ZoomIn).duration(5000)
                        .playOn(v.findViewById(R.id.circle_1));

                YoYo.with(Techniques.ZoomIn).duration(5000)
                        .playOn(v.findViewById(R.id.circle_2));

                YoYo.with(Techniques.ZoomIn).duration(5000)
                        .playOn(v.findViewById(R.id.circle_3));

            } else if (position == 1) {

                Home.rel_footer.setVisibility(View.GONE);

                v = inflater.inflate(R.layout.qrcode_scanner_promotion, container,
                        false);

                YoYo.with(Techniques.Landing).duration(5000)
                        .playOn(v.findViewById(R.id.imgView_iphone));

                YoYo.with(Techniques.Landing).duration(5000)
                        .playOn(v.findViewById(R.id.imgView_ipad));

            } else if (position == 2) {

                Home.rel_footer.setVisibility(View.GONE);

                v = inflater.inflate(R.layout.deals_promotion, container, false);

                YoYo.with(Techniques.ZoomIn).duration(5000)
                        .playOn(v.findViewById(R.id.imgView_iphone_left));

                YoYo.with(Techniques.ZoomIn).duration(5000)
                        .playOn(v.findViewById(R.id.imageView_iphone_front));

                YoYo.with(Techniques.ZoomIn).duration(5000)
                        .playOn(v.findViewById(R.id.imgView_iphone_right));

            }

            return v;
        }
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-06-12 07:57:22

在我看来,如果您希望看到每个页面上的动画更改,则不应该在onCreateView中应用动画。您应该使用OnPageChangeListener界面,并在用户更改寻呼机(切换到另一个页面)后将动画应用到那里。

一个简单的代码片段让你开始。

代码语言:javascript
复制
mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener(){

    @Override
    public void onPageSelected (int position){
        // Apply animations here w.r.t the position
    }

    ... Other overridden methods ...
});
票数 1
EN

Stack Overflow用户

发布于 2015-06-12 07:57:00

代码语言:javascript
复制
mViewPager.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageSelected(int arg0) {
            // TODO Auto-generated method stub
            switch (arg0) {
            case 1:
                //load ur animations here
                break;

            default:
                break;
            }
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onPageScrollStateChanged(int arg0) {
            // TODO Auto-generated method stub

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

https://stackoverflow.com/questions/30797227

复制
相关文章

相似问题

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