简体   繁体   English

Google如何在他们的G +应用中获得动画帖子?

[英]How does Google achieve animated posts in their G+ app?

I like the animation that occurs when scrolling through posts in the Google+ app, but I can't work out how they achieve it. 我喜欢滚动浏览Google+应用中的帖子时出现的动画,但我无法弄清楚他们是如何实现的。

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. 我不是在寻找动画本身,而是我如何将任何动画应用于可滚动项目列表。

Thanks. 谢谢。

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);
}

Scrolling down the list should trigger alpha animation once new TextView s become visible. 向下滚动列表应在新TextView变为可见时触发alpha动画。

有一个库,它似乎做得很好: https//github.com/cuub/sugared-list-animations

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 联系人应用中的自定义操作(类似于G +) - Custom actions in Contacts app (similar to G+) Android应用程式介面,例如g + - Android app interface like g+ 如何在Android应用程序中添加Google+ - how to add a G+ follow in android application 如何制作类似于Gmail或G +的“进度栏”? - How to make a “progressbar” similar to Gmail or G+? 如何使用Facebook好友制作Android多人游戏? (Google Play游戏服务仅使用G +) - How to make Android Multiplayer Games using Facebook friends? (Google Play Game Services uses G+ only) 如何通过G + Android SDK在Google+上的一篇文章中上传多张照片? - How can I upload multiple photos in one post on Google+ from G+ Android SDK? 如何在不使用Intent的情况下从Android分享Google Plus(G +)中的文字和图像? - How to share text & image in Google Plus (G+) from android without using Intent? 如何在Android上的G +中修复boolean com.google.android.gms.common.ConnectionResult.hasResolution()空引用 - How to fix boolean com.google.android.gms.common.ConnectionResult.hasResolution() Null reference in G+ on Android 如何在点击并使用全宽时让Spinner项目显示在自身下方,就像在G + app上一样 - How to let the Spinner items appear below itself when being clicked and with full width, like on G+ app 如何实现“动画化的CollapsingToolbar”? - How to achieve an “animated CollapsingToolbar?”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM