节目单view往左滑动跟踪

试验1

当节目单view往左滑动时,跟踪view的left,right等位置信息。

public void logView(View view) {
    Logger.i(TAG, "left:"+view.getLeft()+", right:"+view.getRight()+", top:"+view.getTop()+", bottom:"+view.getBottom());
}
public void slideView(final View view, final float fromX, final float toX) {
    Logger.i(TAG, "++slideView++");
    Logger.i(TAG, "fromX:"+fromX+", toX:"+toX);
    logView(view);
    Animation.AnimationListener animationListener = new Animation.AnimationListener() {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
        @Override
        public void onAnimationStart(Animation animation) {
            Logger.i(TAG, "++onAnimationStart++");
            logView(view);
        }
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
        @Override
        public void onAnimationRepeat(Animation animation) {
            Logger.i(TAG, "++onAnimationRepeat++");
            logView(view);
        }
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
        @Override
        public void onAnimationEnd(Animation animation) {
            Logger.i(TAG, "++onAnimationEnd++");
            logView(view);
            float offset = toX - fromX;
            view.setLeft(view.getLeft() + (int)offset);
            view.setRight(view.getRight() + (int)offset);
            Logger.i(TAG, "++modify left & right++");
            logView(view);
            view.requestLayout();
            Logger.i(TAG, "++requestLayout++");
            logView(view);
        }
    };
    TranslateAnimation animation = new TranslateAnimation(fromX, toX, 0, 0);
    animation.setInterpolator(new OvershootInterpolator());
    animation.setDuration(500);
    animation.setStartOffset(0);
    animation.setAnimationListener(animationListener);
    view.startAnimation(animation);
}

结果是:通过动画滑到左边之后,又自己滑回来了。

打印出来的日志(如下)

11-13 11:18:19.703: D/PullToRefreshView(7813): ++onFling++
11-13 11:18:19.703: D/PullToRefreshView(7813): velocityX:-1714.6082, velocityY:926.9663
11-13 11:18:19.703: D/WatchTvFragment(7813): ++slideRight2LeftProgramView++
11-13 11:18:19.703: D/WatchTvFragment(7813): ++slideView++
11-13 11:18:19.703: D/WatchTvFragment(7813): fromX:0.0, toX:-426.0
11-13 11:18:19.703: D/WatchTvFragment(7813): left:427, right:986, top:0, bottom:703
11-13 11:18:19.703: D/PullToRefreshView(7813): ++onTouchEvent++
11-13 11:18:19.723: D/WatchTvFragment(7813): ++onAnimationStart++
11-13 11:18:19.723: D/WatchTvFragment(7813): left:427, right:986, top:0, bottom:703
11-13 11:18:20.243: D/WatchTvFragment(7813): ++onAnimationEnd++
11-13 11:18:20.243: D/WatchTvFragment(7813): left:427, right:986, top:0, bottom:703
11-13 11:18:20.243: D/WatchTvFragment(7813): ++modify left & right++
11-13 11:18:20.243: D/WatchTvFragment(7813): left:1, right:560, top:0, bottom:703
11-13 11:18:20.243: D/WatchTvFragment(7813): ++requestLayout++
11-13 11:18:20.243: D/WatchTvFragment(7813): left:1, right:560, top:0, bottom:703

试验2

如果将上面代码中的第31,32,33行注释掉,结果是滑到左边就不再滑回来,但是会闪一下。

打印的日志如下

11-13 11:30:55.843: D/PullToRefreshView(8595): ++onFling++
11-13 11:30:55.843: D/PullToRefreshView(8595): velocityX:-1911.3549, velocityY:379.53253
11-13 11:30:55.843: D/WatchTvFragment(8595): ++slideRight2LeftProgramView++
11-13 11:30:55.843: D/WatchTvFragment(8595): ++slideView++
11-13 11:30:55.843: D/WatchTvFragment(8595): fromX:0.0, toX:-426.0
11-13 11:30:55.843: D/WatchTvFragment(8595): left:427, right:986, top:0, bottom:703
11-13 11:30:55.843: D/PullToRefreshView(8595): ++onTouchEvent++
11-13 11:30:55.853: D/WatchTvFragment(8595): ++onAnimationStart++
11-13 11:30:55.853: D/WatchTvFragment(8595): left:427, right:986, top:0, bottom:703
11-13 11:30:56.353: D/WatchTvFragment(8595): ++onAnimationEnd++
11-13 11:30:56.353: D/WatchTvFragment(8595): left:427, right:986, top:0, bottom:703
11-13 11:30:56.353: D/WatchTvFragment(8595): ++modify left & right++
11-13 11:30:56.353: D/WatchTvFragment(8595): left:1, right:560, top:0, bottom:703

试验3

修改上面的代码(如下)。在代码中添加clearAnimation方法。

    public void slideView(final View view, final float fromX, final float toX) {
        Logger.i(TAG, "++slideView++");
        Logger.i(TAG, "fromX:"+fromX+", toX:"+toX);
        logView(view);
        Animation.AnimationListener animationListener = new Animation.AnimationListener() {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
            @Override
            public void onAnimationStart(Animation animation) {
                Logger.i(TAG, "++onAnimationStart++");
                logView(view);
            }
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
            @Override
            public void onAnimationRepeat(Animation animation) {
                Logger.i(TAG, "++onAnimationRepeat++");
                logView(view);
            }
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
            @Override
            public void onAnimationEnd(Animation animation) {
                Logger.i(TAG, "++onAnimationEnd++");
                logView(view);
                view.clearAnimation();
                Logger.i(TAG, "++clear animation++");
                logView(view);
                float offset = toX - fromX;
                view.setLeft(view.getLeft() + (int)offset);
                view.setRight(view.getRight() + (int)offset);
                Logger.i(TAG, "++modify left & right++");
                logView(view);
//              view.requestLayout();
//              Logger.i(TAG, "++requestLayout++");
//              logView(view);
            }
        };
        TranslateAnimation animation = new TranslateAnimation(fromX, toX, 0, 0);
        animation.setInterpolator(new OvershootInterpolator());
        animation.setDuration(500);
        animation.setStartOffset(0);
        animation.setAnimationListener(animationListener);
        view.startAnimation(animation);
    }

执行后的结果是:滑到左边不再自己滑回来,也不会闪一下。

打印的日志如下

11-13 11:52:14.513: D/PullToRefreshView(10767): ++onFling++
11-13 11:52:14.513: D/PullToRefreshView(10767): velocityX:-1192.356, velocityY:317.86694
11-13 11:52:14.513: D/WatchTvFragment(10767): ++slideRight2LeftProgramView++
11-13 11:52:14.513: D/WatchTvFragment(10767): ++slideView++
11-13 11:52:14.513: D/WatchTvFragment(10767): fromX:0.0, toX:-426.0
11-13 11:52:14.513: D/WatchTvFragment(10767): left:427, right:986, top:0, bottom:703
11-13 11:52:14.513: D/PullToRefreshView(10767): ++onTouchEvent++
11-13 11:52:14.513: D/WatchTvFragment(10767): ++onAnimationStart++
11-13 11:52:14.513: D/WatchTvFragment(10767): left:427, right:986, top:0, bottom:703
11-13 11:52:15.023: D/WatchTvFragment(10767): ++onAnimationEnd++
11-13 11:52:15.023: D/WatchTvFragment(10767): left:427, right:986, top:0, bottom:703
11-13 11:52:15.023: D/WatchTvFragment(10767): ++clear animation++
11-13 11:52:15.023: D/WatchTvFragment(10767): left:427, right:986, top:0, bottom:703
11-13 11:52:15.023: D/WatchTvFragment(10767): ++modify left & right++
11-13 11:52:15.023: D/WatchTvFragment(10767): left:1, right:560, top:0, bottom:703

试验4

如果将楼上第31,32,33行的代码取消注释,结果是:

滑到左边自己会滑回来。

打印的日志同楼上相同,只是在最后多了两条:

11-13 11:52:15.023: D/WatchTvFragment(10767): ++requestLayout++
11-13 11:52:15.033: D/WatchTvFragment(10767): left:1, right:560, top:0, bottom:703

试验5

楼上是从右往左滑的操作,下面是从左往右的操作,滑动效果明显比较乱,打印的日志也不符合预期。其中left,right值已经不同于上次操作后日志显示的数值。

打印的日志如下

11-13 11:57:41.683: D/PullToRefreshView(10767): ++onFling++
11-13 11:57:41.683: D/PullToRefreshView(10767): velocityX:418.54935, velocityY:-59.648247
11-13 11:57:41.683: D/WatchTvFragment(10767): ++slideLeft2RightProgramView++
11-13 11:57:41.683: D/WatchTvFragment(10767): ++slideView++
11-13 11:57:41.683: D/WatchTvFragment(10767): fromX:-426.0, toX:0.0
11-13 11:57:41.683: D/WatchTvFragment(10767): left:427, right:986, top:0, bottom:703
11-13 11:57:41.683: D/PullToRefreshView(10767): ++onTouchEvent++
11-13 11:57:41.713: D/WatchTvFragment(10767): ++onAnimationStart++
11-13 11:57:41.713: D/WatchTvFragment(10767): left:427, right:986, top:0, bottom:703
11-13 11:57:42.223: D/WatchTvFragment(10767): ++onAnimationEnd++
11-13 11:57:42.223: D/WatchTvFragment(10767): left:427, right:986, top:0, bottom:703
11-13 11:57:42.223: D/WatchTvFragment(10767): ++clear animation++
11-13 11:57:42.223: D/WatchTvFragment(10767): left:427, right:986, top:0, bottom:703
11-13 11:57:42.223: D/WatchTvFragment(10767): ++modify left & right++
11-13 11:57:42.223: D/WatchTvFragment(10767): left:853, right:1412, top:0, bottom:703
11-13 11:57:42.223: D/WatchTvFragment(10767): ++requestLayout++
11-13 11:57:42.223: D/WatchTvFragment(10767): left:853, right:1412, top:0, bottom:703

试验6

修改楼上的代码(如下),不调用view.requestLayout(),取而代之执行view.layout(l,t,r,b)。

    public void slideView(final View view, final float fromX, final float toX) {
        Logger.i(TAG, "++slideView++");
        Logger.i(TAG, "fromX:"+fromX+", toX:"+toX);
        logView(view);
        Animation.AnimationListener animationListener = new Animation.AnimationListener() {
                                                                                                                                                                                                                                                                                                                                                                                     
            @Override
            public void onAnimationStart(Animation animation) {
                Logger.i(TAG, "++onAnimationStart++");
                logView(view);
            }
                                                                                                                                                                                                                                                                                                                                                                                     
            @Override
            public void onAnimationRepeat(Animation animation) {
                Logger.i(TAG, "++onAnimationRepeat++");
                logView(view);
            }
                                                                                                                                                                                                                                                                                                                                                                                     
            @Override
            public void onAnimationEnd(Animation animation) {
                Logger.i(TAG, "++onAnimationEnd++");
                logView(view);
                view.clearAnimation();
                Logger.i(TAG, "++clear animation++");
                logView(view);
                float offset = toX - fromX;
                view.setLeft(view.getLeft() + (int)offset);
                view.setRight(view.getRight() + (int)offset);
                Logger.i(TAG, "++modify left & right++");
                logView(view);
//              view.requestLayout();
//              Logger.i(TAG, "++requestLayout++");
//              logView(view);
                view.layout(view.getLeft(), view.getTop(), view.getRight(), view.getBottom());
                Logger.i(TAG, "layout("+view.getLeft()+"," +view.getTop()+"," +view.getRight()+"," +view.getBottom()+")");
                logView(view);
            }
        };
        TranslateAnimation animation = new TranslateAnimation(fromX, toX, 0, 0);
        animation.setInterpolator(new OvershootInterpolator());
        animation.setDuration(500);
        animation.setStartOffset(0);
        animation.setAnimationListener(animationListener);
        view.startAnimation(animation);
    }

程序执行记录如下:

(1)从右往左滑,没有闪屏,也没有自己滑回去,结果在预期位置。

11-13 12:06:20.353: D/PullToRefreshView(11605): ++onFling++
11-13 12:06:20.353: D/PullToRefreshView(11605): velocityX:-1541.0804, velocityY:138.03113
11-13 12:06:20.353: D/WatchTvFragment(11605): ++slideRight2LeftProgramView++
11-13 12:06:20.353: D/WatchTvFragment(11605): ++slideView++
11-13 12:06:20.353: D/WatchTvFragment(11605): fromX:0.0, toX:-426.0
11-13 12:06:20.353: D/WatchTvFragment(11605): left:427, right:986, top:0, bottom:703
11-13 12:06:20.353: D/PullToRefreshView(11605): ++onTouchEvent++
11-13 12:06:20.353: D/WatchTvFragment(11605): ++onAnimationStart++
11-13 12:06:20.353: D/WatchTvFragment(11605): left:427, right:986, top:0, bottom:703
11-13 12:06:20.873: D/WatchTvFragment(11605): ++onAnimationEnd++
11-13 12:06:20.873: D/WatchTvFragment(11605): left:427, right:986, top:0, bottom:703
11-13 12:06:20.873: D/WatchTvFragment(11605): ++clear animation++
11-13 12:06:20.873: D/WatchTvFragment(11605): left:427, right:986, top:0, bottom:703
11-13 12:06:20.873: D/WatchTvFragment(11605): ++modify left & right++
11-13 12:06:20.873: D/WatchTvFragment(11605): left:1, right:560, top:0, bottom:703
11-13 12:06:20.873: D/WatchTvFragment(11605): layout(1,0,560,703)
11-13 12:06:20.873: D/WatchTvFragment(11605): left:1, right:560, top:0, bottom:703

(2)从左往右滑,滑到原处之后,又往右滑了一段出去,结果不在预期位置。

11-13 12:06:45.853: D/PullToRefreshView(11605): ++onFling++
11-13 12:06:45.853: D/PullToRefreshView(11605): velocityX:2519.4294, velocityY:-122.3643
11-13 12:06:45.853: D/WatchTvFragment(11605): ++slideLeft2RightProgramView++
11-13 12:06:45.853: D/WatchTvFragment(11605): ++slideView++
11-13 12:06:45.853: D/WatchTvFragment(11605): fromX:-426.0, toX:0.0
11-13 12:06:45.853: D/WatchTvFragment(11605): left:1, right:560, top:0, bottom:703
11-13 12:06:45.853: D/PullToRefreshView(11605): ++onTouchEvent++
11-13 12:06:45.873: D/WatchTvFragment(11605): ++onAnimationStart++
11-13 12:06:45.873: D/WatchTvFragment(11605): left:427, right:986, top:0, bottom:703
11-13 12:06:46.393: D/WatchTvFragment(11605): ++onAnimationEnd++
11-13 12:06:46.393: D/WatchTvFragment(11605): left:427, right:986, top:0, bottom:703
11-13 12:06:46.393: D/WatchTvFragment(11605): ++clear animation++
11-13 12:06:46.393: D/WatchTvFragment(11605): left:427, right:986, top:0, bottom:703
11-13 12:06:46.393: D/WatchTvFragment(11605): ++modify left & right++
11-13 12:06:46.393: D/WatchTvFragment(11605): left:853, right:1412, top:0, bottom:703
11-13 12:06:46.393: D/WatchTvFragment(11605): layout(853,0,1412,703)
11-13 12:06:46.393: D/WatchTvFragment(11605): left:853, right:1412, top:0, bottom:703

(3)从右往左滑,滑到原处之后,再往左滑了一段,结果在预期位置。

11-13 12:07:43.193: D/PullToRefreshView(11605): ++onFling++
11-13 12:07:43.193: D/PullToRefreshView(11605): velocityX:-6216.4023, velocityY:-10.168142
11-13 12:07:43.193: D/WatchTvFragment(11605): ++slideRight2LeftProgramView++
11-13 12:07:43.193: D/WatchTvFragment(11605): ++slideView++
11-13 12:07:43.193: D/WatchTvFragment(11605): fromX:0.0, toX:-426.0
11-13 12:07:43.193: D/WatchTvFragment(11605): left:427, right:986, top:0, bottom:703
11-13 12:07:43.193: D/PullToRefreshView(11605): ++onTouchEvent++
11-13 12:07:43.223: I/dalvikvm(11605): Jit: resizing JitTable from 4096 to 8192
11-13 12:07:43.253: D/WatchTvFragment(11605): ++onAnimationStart++
11-13 12:07:43.253: D/WatchTvFragment(11605): left:427, right:986, top:0, bottom:703
11-13 12:07:43.753: D/WatchTvFragment(11605): ++onAnimationEnd++
11-13 12:07:43.753: D/WatchTvFragment(11605): left:427, right:986, top:0, bottom:703
11-13 12:07:43.753: D/WatchTvFragment(11605): ++clear animation++
11-13 12:07:43.753: D/WatchTvFragment(11605): left:427, right:986, top:0, bottom:703
11-13 12:07:43.753: D/WatchTvFragment(11605): ++modify left & right++
11-13 12:07:43.753: D/WatchTvFragment(11605): left:1, right:560, top:0, bottom:703
11-13 12:07:43.753: D/WatchTvFragment(11605): layout(1,0,560,703)
11-13 12:07:43.753: D/WatchTvFragment(11605): left:1, right:560, top:0, bottom:703

试验7

以上调用的slidRight2LeftProgramView和slideLeft2RightProgramView两个方法的实现是

public void slideRight2LeftProgramView() {
    if(bAtLeft) return;
    bAtLeft = true;
    Logger.i(TAG, "++slideRight2LeftProgramView++");
    slideView(programView, 0, -channelView.getMeasuredWidth());
}
public void slideLeft2RightProgramView() {
    if(!bAtLeft) return;
    bAtLeft = false;
    Logger.i(TAG, "++slideLeft2RightProgramView++");
    slideView(programView, -channelView.getMeasuredWidth(), 0);
}

修改slideLeft2RightProgramView的实现(代码如下)

public void slideLeft2RightProgramView() {
    if(!bAtLeft) return;
    bAtLeft = false;
    Logger.i(TAG, "++slideLeft2RightProgramView++");
    slideView(programView, 0, channelView.getMeasuredWidth());
}

再执行程序,

(1)从左往右滑,打印日志

11-13 13:13:57.953: D/PullToRefreshView(14409): ++onFling++
11-13 13:13:57.953: D/PullToRefreshView(14409): velocityX:-299.23645, velocityY:120.557686
11-13 13:13:57.953: D/WatchTvFragment(14409): ++slideRight2LeftProgramView++
11-13 13:13:57.953: D/WatchTvFragment(14409): ++slideView++
11-13 13:13:57.953: D/WatchTvFragment(14409): fromX:0.0, toX:-426.0
11-13 13:13:57.953: D/WatchTvFragment(14409): left:427, right:986, top:0, bottom:703
11-13 13:13:57.953: D/PullToRefreshView(14409): ++onTouchEvent++
11-13 13:13:57.963: D/WatchTvFragment(14409): ++onAnimationStart++
11-13 13:13:57.963: D/WatchTvFragment(14409): left:427, right:986, top:0, bottom:703
11-13 13:13:58.473: D/WatchTvFragment(14409): ++onAnimationEnd++
11-13 13:13:58.473: D/WatchTvFragment(14409): left:427, right:986, top:0, bottom:703
11-13 13:13:58.473: D/WatchTvFragment(14409): ++clear animation++
11-13 13:13:58.473: D/WatchTvFragment(14409): left:427, right:986, top:0, bottom:703
11-13 13:13:58.473: D/WatchTvFragment(14409): ++modify left & right++
11-13 13:13:58.473: D/WatchTvFragment(14409): left:1, right:560, top:0, bottom:703
11-13 13:13:58.483: D/WatchTvFragment(14409): layout(1,0,560,703)
11-13 13:13:58.483: D/WatchTvFragment(14409): left:1, right:560, top:0, bottom:703

从左往右滑,打印日志

11-13 13:14:22.633: D/PullToRefreshView(14409): ++onFling++
11-13 13:14:22.633: D/PullToRefreshView(14409): velocityX:8061.372, velocityY:-391.0305
11-13 13:14:22.633: D/WatchTvFragment(14409): ++slideLeft2RightProgramView++
11-13 13:14:22.633: D/WatchTvFragment(14409): ++slideView++
11-13 13:14:22.633: D/WatchTvFragment(14409): fromX:0.0, toX:426.0
11-13 13:14:22.633: D/WatchTvFragment(14409): left:427, right:986, top:0, bottom:703
11-13 13:14:22.633: D/PullToRefreshView(14409): ++onTouchEvent++
11-13 13:14:22.643: D/WatchTvFragment(14409): ++onAnimationStart++
11-13 13:14:22.643: D/WatchTvFragment(14409): left:427, right:986, top:0, bottom:703
11-13 13:14:23.163: D/WatchTvFragment(14409): ++onAnimationEnd++
11-13 13:14:23.163: D/WatchTvFragment(14409): left:427, right:986, top:0, bottom:703
11-13 13:14:23.163: D/WatchTvFragment(14409): ++clear animation++
11-13 13:14:23.163: D/WatchTvFragment(14409): left:427, right:986, top:0, bottom:703
11-13 13:14:23.163: D/WatchTvFragment(14409): ++modify left & right++
11-13 13:14:23.163: D/WatchTvFragment(14409): left:853, right:1412, top:0, bottom:703
11-13 13:14:23.163: D/WatchTvFragment(14409): layout(853,0,1412,703)
11-13 13:14:23.163: D/WatchTvFragment(14409): left:853, right:1412, top:0, bottom:703

从上面的日志分析得出结果:从右往左滑动之后,left的值从427变为1;但是下次从左往右滑动时,left不是从1开始,而是从427开始。

试验8

在slieView方法调用startAnimation之前,调用animation的setFillAfter方法。

TranslateAnimation animation = new TranslateAnimation(fromX, toX, 0, 0);
animation.setInterpolator(new OvershootInterpolator());
animation.setDuration(500);
animation.setStartOffset(0);
animation.setAnimationListener(animationListener);
animation.setFillAfter(true);
view.startAnimation(animation);

然后再执行程序,打印日志

(1)从右往左滑

11-13 13:25:40.013: D/PullToRefreshView(15284): ++onFling++
11-13 13:25:40.013: D/PullToRefreshView(15284): velocityX:-876.824, velocityY:100.79468
11-13 13:25:40.013: D/WatchTvFragment(15284): ++slideRight2LeftProgramView++
11-13 13:25:40.013: D/WatchTvFragment(15284): ++slideView++
11-13 13:25:40.013: D/WatchTvFragment(15284): fromX:0.0, toX:-426.0
11-13 13:25:40.013: D/WatchTvFragment(15284): left:427, right:986, top:0, bottom:703
11-13 13:25:40.013: D/PullToRefreshView(15284): ++onTouchEvent++
11-13 13:25:40.023: D/WatchTvFragment(15284): ++onAnimationStart++
11-13 13:25:40.023: D/WatchTvFragment(15284): left:427, right:986, top:0, bottom:703
11-13 13:25:40.543: D/WatchTvFragment(15284): ++onAnimationEnd++
11-13 13:25:40.543: D/WatchTvFragment(15284): left:427, right:986, top:0, bottom:703
11-13 13:25:40.543: D/WatchTvFragment(15284): ++clear animation++
11-13 13:25:40.543: D/WatchTvFragment(15284): left:427, right:986, top:0, bottom:703
11-13 13:25:40.543: D/WatchTvFragment(15284): ++modify left & right++
11-13 13:25:40.543: D/WatchTvFragment(15284): left:1, right:560, top:0, bottom:703
11-13 13:25:40.543: D/WatchTvFragment(15284): layout(1,0,560,703)
11-13 13:25:40.543: D/WatchTvFragment(15284): left:1, right:560, top:0, bottom:703

(2)从左往右滑

11-13 13:26:00.083: D/PullToRefreshView(15284): ++onFling++
11-13 13:26:00.093: D/PullToRefreshView(15284): velocityX:1673.9954, velocityY:-381.92545
11-13 13:26:00.093: D/WatchTvFragment(15284): ++slideLeft2RightProgramView++
11-13 13:26:00.093: D/WatchTvFragment(15284): ++slideView++
11-13 13:26:00.093: D/WatchTvFragment(15284): fromX:0.0, toX:426.0
11-13 13:26:00.093: D/WatchTvFragment(15284): left:1, right:560, top:0, bottom:703
11-13 13:26:00.093: D/PullToRefreshView(15284): ++onTouchEvent++
11-13 13:26:00.103: D/WatchTvFragment(15284): ++onAnimationStart++
11-13 13:26:00.103: D/WatchTvFragment(15284): left:427, right:986, top:0, bottom:703
11-13 13:26:00.613: D/WatchTvFragment(15284): ++onAnimationEnd++
11-13 13:26:00.613: D/WatchTvFragment(15284): left:427, right:986, top:0, bottom:703
11-13 13:26:00.613: D/WatchTvFragment(15284): ++clear animation++
11-13 13:26:00.613: D/WatchTvFragment(15284): left:427, right:986, top:0, bottom:703
11-13 13:26:00.613: D/WatchTvFragment(15284): ++modify left & right++
11-13 13:26:00.613: D/WatchTvFragment(15284): left:853, right:1412, top:0, bottom:703
11-13 13:26:00.613: D/WatchTvFragment(15284): layout(853,0,1412,703)
11-13 13:26:00.613: D/WatchTvFragment(15284): left:853, right:1412, top:0, bottom:703

(3)从右往左滑

11-13 13:26:18.113: D/PullToRefreshView(15284): ++onFling++
11-13 13:26:18.113: D/PullToRefreshView(15284): velocityX:-1004.43695, velocityY:-184.0056
11-13 13:26:18.113: D/WatchTvFragment(15284): ++slideRight2LeftProgramView++
11-13 13:26:18.113: D/WatchTvFragment(15284): ++slideView++
11-13 13:26:18.113: D/WatchTvFragment(15284): fromX:0.0, toX:-426.0
11-13 13:26:18.113: D/WatchTvFragment(15284): left:853, right:1412, top:0, bottom:703
11-13 13:26:18.113: D/PullToRefreshView(15284): ++onTouchEvent++
11-13 13:26:18.133: D/WatchTvFragment(15284): ++onAnimationStart++
11-13 13:26:18.133: D/WatchTvFragment(15284): left:427, right:986, top:0, bottom:703
11-13 13:26:18.643: D/WatchTvFragment(15284): ++onAnimationEnd++
11-13 13:26:18.643: D/WatchTvFragment(15284): left:427, right:986, top:0, bottom:703
11-13 13:26:18.643: D/WatchTvFragment(15284): ++clear animation++
11-13 13:26:18.643: D/WatchTvFragment(15284): left:427, right:986, top:0, bottom:703
11-13 13:26:18.643: D/WatchTvFragment(15284): ++modify left & right++
11-13 13:26:18.643: D/WatchTvFragment(15284): left:1, right:560, top:0, bottom:703
11-13 13:26:18.643: D/WatchTvFragment(15284): layout(1,0,560,703)
11-13 13:26:18.643: D/WatchTvFragment(15284): left:1, right:560, top:0, bottom:703

(4)从左往右滑

11-13 13:26:32.733: D/PullToRefreshView(15284): ++onFling++
11-13 13:26:32.733: D/PullToRefreshView(15284): velocityX:2957.727, velocityY:-363.21652
11-13 13:26:32.733: D/WatchTvFragment(15284): ++slideLeft2RightProgramView++
11-13 13:26:32.733: D/WatchTvFragment(15284): ++slideView++
11-13 13:26:32.733: D/WatchTvFragment(15284): fromX:0.0, toX:426.0
11-13 13:26:32.733: D/WatchTvFragment(15284): left:1, right:560, top:0, bottom:703
11-13 13:26:32.733: D/PullToRefreshView(15284): ++onTouchEvent++
11-13 13:26:32.733: D/WatchTvFragment(15284): ++onAnimationStart++
11-13 13:26:32.733: D/WatchTvFragment(15284): left:427, right:986, top:0, bottom:703
11-13 13:26:33.243: D/WatchTvFragment(15284): ++onAnimationEnd++
11-13 13:26:33.243: D/WatchTvFragment(15284): left:427, right:986, top:0, bottom:703
11-13 13:26:33.253: D/WatchTvFragment(15284): ++clear animation++
11-13 13:26:33.253: D/WatchTvFragment(15284): left:427, right:986, top:0, bottom:703
11-13 13:26:33.253: D/WatchTvFragment(15284): ++modify left & right++
11-13 13:26:33.263: D/WatchTvFragment(15284): left:853, right:1412, top:0, bottom:703
11-13 13:26:33.263: D/WatchTvFragment(15284): layout(853,0,1412,703)
11-13 13:26:33.263: D/WatchTvFragment(15284): left:853, right:1412, top:0, bottom:703

从日志中分析得出结果:不管从左往右滑还是从右往左滑之后,下次再调用slideView时view的left值保持上次动画结束的位置。但是在onAnimationStart中,view的left值就发生了改变,又还原为view刚加载完时的初始left数值(此时为427)。


你可能感兴趣的:(public,信息,bottom,节目单)