androidAndroid开发经验谈Android开发

模仿android 7.x原生shortcut UI效果

2018-03-01  本文已影响578人  _deadline

https://github.com/niniloveyou/ShortcutLayout (感觉不错的话,给star下)

先来看个效果图,图片有点模糊,将就下 lAHPBbCc1XHXyx3NAyDNAZA_400_800.gif

第一次看到原生的shortcut 动画的时候,就感觉很灵动,很喜欢,刚好项目中有类似的需要,所以就自己动手作了个类似的,效果还跟原生的有点差距。

写这个效果,主要需要考虑以下几个问题:

   public void expand(int itemAnimationTime, int itemAnimationGap){
        for (int i = 0; i < getChildCount(); i++) {
            if(getChildAt(i) instanceof ShortcutView){
                ((ShortcutView) getChildAt(i)).expand(true, itemAnimationTime, (getChildCount() - i) * itemAnimationGap);
            }
        }
        isExpanded = true;
    }

说了这么多,代码就不贴了,感兴趣的话github上看代码,如果对你有帮助star下吧,谢谢各位观众。

上一篇 下一篇

猜你喜欢

热点阅读