有活性/片段转换与pre-棒棒糖设备兼容? [英] Are Activity/Fragment Transitions compatible with pre-Lollipop devices?

查看:189
本文介绍了有活性/片段转换与pre-棒棒糖设备兼容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让使用共享元素一个pre-棒棒糖装置(4.x版)上的活动转型。可能吗?到目前为止,我想这样的:

I'm trying to make an Activity Transition using Shared Elements on a pre-Lollipop device (4.x). Is it possible? So far, I'm trying this:

public class RewardDetail extends ActionBarActivity {
    @Override
    public void onCreate(final Bundle savedInstanceState) {
        ...

        ViewCompat.setTransitionName(imageView, TRANSITION_NAME);
    }

    ...

    public static void launch(ActionBarActivity activity, View transitionView, WelcomeReward detailData) {
        ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, transitionView, TRANSITION_NAME);
        Intent intent = new Intent(activity, RewardDetail.class);
        intent.putExtra(PARAM_DATA, detailData);
        ActivityCompat.startActivity(activity, intent, options.toBundle());
    }
}

调用:

@Override
public void onClick(final View v) {
    int position = recyclerView.getChildPosition(v);
    WelcomeReward welcomeReward = data.get(position);
    RewardDetail.launch(WelcomeRewardActivity.this, v.findViewById(R.id.reward_view), welcomeReward);
}

但它会导致常规过渡(没有共享的元素)。任何想法?

But it results in a "regular" transition (no shared element). Any ideas?

修改

根据这段视频,它可以做:

According to this video, it could be done:

<一个href="https://www.youtube.com/watch?v=RhiPJByIMrM&index=8&list=WL">https://www.youtube.com/watch?v=RhiPJByIMrM&index=8&list=WL

有没有已经在实施本作pre棒棒糖?库

Is there a library already implementing this for pre Lollipop ?

推荐答案

没有,活动/片段转换是不可能的pre-棒棒糖设备。按照文档

No, Activity/Fragment Transitions are not possible on pre-Lollipop devices. According to the documentation:

开始用额外的启动信息的活动。

Start an activity with additional launch information, if able.

在安卓4.1+其他选项进行了介绍,以便在活动推出动画的更多控制。应用程序可以使用此方法与ActivityOptionsCompat可用时使用这些动画。当具备此功能不存在,该活动将正常启动了平台的版本上运行。

In Android 4.1+ additional options were introduced to allow for more control on activity launch animations. Applications can use this method along with ActivityOptionsCompat to use these animations when available. When run on versions of the platform where this feature does not exist the activity will be launched normally.

又见乔治山的回答这个计算器的问题

这篇关于有活性/片段转换与pre-棒棒糖设备兼容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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