当前位置: 主页 > 开源代码 >

高仿ios消息列表滑动效果,listview

分享

介绍:

模仿iOS7短信界面的滑滑的惯性动画效果 ,使用:像普通 ListView 那样用就好了
本项目来源:https://github.com/kot32go/iOSMessageLi
项目主要介绍:
通过自定义iOSMessageList,继承ListView,监听listview 的滚动事件OnScrollListener,
在onScroll中调用如下动画实现的。

    private void startAnimation(final int firstIndex, final int lastIndex) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 1; i < lastIndex - firstIndex; i++) {
                    View child = getChildAt(i);
                    if (isScrollToUp) {
                        child = getChildAt(lastIndex - firstIndex - i);
                    }
                    Message message = new Message();
                    message.what = START_ANIMATION;
                    message.obj = child;
                    message.arg1 = i;
                    message.arg2 = lastIndex - firstIndex - i;

                    animationHandler.sendMessage(message);
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }

                }
            }
        }).start();


    }

运行效果: