谷歌是如何实现自己的G +应用动画帖子? [英] How does Google achieve animated posts in their G+ app?

查看:147
本文介绍了谷歌是如何实现自己的G +应用动画帖子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢通过Google+应用帖子滚动时出现的动画,但我不能工作了他们是如何实现它。

I like the animation that occurs when scrolling through posts in the Google+ app, but I can't work out how they achieve it.

都采用什么技术,他们似乎动画帖子?我不是在寻找的动画本身,只是我怎么会应用任何动画,以滚动的项目列表。

What techniques are employed to animate posts as they appear? I'm not looking for the animation itself, just how I'd apply any animation to a list of scrollable items.

感谢。

推荐答案

在某些测试中,我想我得到了类似的工作,事情;

After some testing I think I got something similar to work;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final LinearLayout list = new LinearLayout(this);
    list.setOrientation(LinearLayout.VERTICAL);

    ScrollView scrollView = new ScrollView(this) {
        Rect mRect = new Rect();

        @Override
        public void onLayout(boolean changed, int l, int t, int r, int b) {
            super.onLayout(changed, l, t, r, b);

            for (int i = 0; i < list.getChildCount(); ++i) {
                View v = list.getChildAt(i);

                // Tag initially visible Views as 'true'.
                mRect.set(l, t, r, b);
                v.setTag(getChildVisibleRect(v, mRect, null));                  
            }
        }

        @Override
        public void onScrollChanged(int l, int t, int oldl, int oldt) {
            super.onScrollChanged(l, t, oldl, oldt);

            for (int i = 0; i < list.getChildCount(); ++i) {
                View v = list.getChildAt(i);
                mRect.set(getLeft(), getTop(), getRight(), getBottom());

                // If tag == 'false' and View is visible we know that
                // View became visible during this scroll event.
                if ((Boolean) v.getTag() == false
                        && getChildVisibleRect(v, mRect, null)) {
                    AlphaAnimation anim = new AlphaAnimation(0, 1);
                    anim.setDuration(1000);
                    v.startAnimation(anim);
                    v.setTag(true);
                }
            }
        }
    };
    scrollView.addView(list);

    for (int i = 0; i < 20; ++i) {
        TextView tv = new TextView(this);
        tv.setText("Test");
        tv.setTextSize(72);
        tv.setTextColor(Color.WHITE);
        tv.setBackgroundColor(Color.GRAY);
        list.addView(tv);
    }

    setContentView(scrollView);
}

向下滚动列表应触发奥飞动漫,一旦新的的TextView 取值变得可见。

这篇关于谷歌是如何实现自己的G +应用动画帖子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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