如何实施"家长对孩子"导航过渡,通过材料设计prescribed [英] How to implement the "parent-to-child" navigational transition as prescribed by Material Design

查看:174
本文介绍了如何实施"家长对孩子"导航过渡,通过材料设计prescribed的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谷歌的材质设计指引prescribe为父母对孩子转变的过渡之后当父组成名单。<一个href=\"http://www.google.com/design/spec/patterns/navigational-transitions.html#navigational-transitions-parent-to-child\"相对=nofollow>(材料设计指南)

Google's Material Design guidelines prescribe the following transition for "parent-to-child" transitions when the parent consists of a list. (Material Design Guidelines)

我如何提供这样的过渡?我不知道提供使之成为可能的内在转变。

How do I provide such a transition? I'm unaware of any inbuilt transition provided to make this possible.

推荐答案

有一个共享的元素开始一个活动

Start an activity with a shared element

为使具有共享的元素两项活动之间的屏幕过渡动画:

To make a screen transition animation between two activities that have a shared element:

在你的主题打开窗口的内容转换。
指定你的风格一个共享的元素过渡。
定义你的XML资源的过渡。
指定一个共同的名字在两个布局共享的元素与 的android:transitionName 属性。
使用ActivityOptions.makeSceneTransitionAnimation()方法。

Enable window content transitions in your theme. Specify a shared elements transition in your style. Define your transition as an XML resource. Assign a common name to the shared elements in both layouts with the android:transitionName attribute. Use the ActivityOptions.makeSceneTransitionAnimation() method.

// get the element that receives the click event
final View imgContainerView = findViewById(R.id.img_container);

// get the common element for the transition in this activity
final View androidRobotView = findViewById(R.id.image_small);

// define a click listener
imgContainerView.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        Intent intent = new Intent(this, Activity2.class);
        // create the transition animation - the images in the layouts
        // of both activities are defined with android:transitionName="robot"
        ActivityOptions options = ActivityOptions
            .makeSceneTransitionAnimation(this, androidRobotView, "robot");
        // start the new activity
        startActivity(intent, options.toBundle());
    }
});

有关您在code生成共享动态视图,使用View.setTransitionName()方法在这两个活动指定一个共同的元素名称。

For shared dynamic views that you generate in your code, use the View.setTransitionName() method to specify a common element name in both activities.

要扭转场景过渡动画,当你完成第二个活动,叫Activity.finishAfterTransition()方法,而不是Activity.finish()。

To reverse the scene transition animation when you finish the second activity, call the Activity.finishAfterTransition() method instead of Activity.finish().

从这里乘自定义活动转变

这篇关于如何实施&QUOT;家长对孩子&QUOT;导航过渡,通过材料设计prescribed的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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