其采用了Android 5.0的活动过渡到问题与ViewPager活动 [英] Having issues using Android 5.0 Activity transitions onto an activity with a ViewPager

查看:340
本文介绍了其采用了Android 5.0的活动过渡到问题与ViewPager活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我们试图在L​​istView创建从图像的整个活动图像过渡,在ViewPager gallery.In的图像做这个转变,我们看到动画的发生ViewPager完成加载/绘图之前。这将导致对ViewPager图像闪烁,使动画看起来很糟糕。

So we're trying to create an across activity image transition from an image in a ListView, to an image in a ViewPager gallery.In doing this transition we're seeing the animation happen before the ViewPager finishes loading/drawing. This causes the image on the ViewPager to flash making the animation look bad.

由于我们把图像上层建筑伪造的ViewPager的外观测试加载。然后,我们从图像在ListView过渡到这个'假'的ImageView,然后藏在过渡完成后。这有助于但仍然没有建立一个流畅的体验,因为一旦ViewPager画完事情会闪烁。

As a test we put an image overtop to fake the look of the ViewPager being loaded. We then transition from the image in the ListView to this 'dummy' ImageView, and then hide it after the transition is complete. This helped but still didn't create a smooth experience since things would flash once the ViewPager finished drawing.

任何提示将AP preciated!

Any tips would be appreciated!

推荐答案

建立了乔治山的回答,您可以尝试添加以下code在被称为活动的的onCreate()方法:

Building off George Mount's answer, you could try adding the following code in your called Activity's onCreate() method:

postponeEnterTransition(); 
viewPager.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { 
    public boolean onPreDraw() { 
        viewPager.getViewTreeObserver().removeOnPreDrawListener(this);
        startPostponedEnterTransition();
        return true;
    }
});

这篇关于其采用了Android 5.0的活动过渡到问题与ViewPager活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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