本帖最后由 Eyebrows_cs 于 2013-07-26 10:19:19 编辑

解决方案 »

  1.   

    你可以使用ViewPager.PageTransformer来定制你的切换动画。
    以下代码来源于官方网站:http://developer.android.com/training/animation/screen-slide.html#pagetransformerpublic class DepthPageTransformer implements ViewPager.PageTransformer {
        private static float MIN_SCALE = 0.75f;    public void transformPage(View view, float position) {
            int pageWidth = view.getWidth();        if (position < -1) { // [-Infinity,-1)
                // This page is way off-screen to the left.
                view.setAlpha(0);        } else if (position <= 0) { // [-1,0]
                // Use the default slide transition when moving to the left page
                view.setAlpha(1);
                view.setTranslationX(0);
                view.setScaleX(1);
                view.setScaleY(1);        } else if (position <= 1) { // (0,1]
                // Fade the page out.
                view.setAlpha(1 - position);            // Counteract the default slide transition
                view.setTranslationX(pageWidth * -position);            // Scale the page down (between MIN_SCALE and 1)
                float scaleFactor = MIN_SCALE
                        + (1 - MIN_SCALE) * (1 - Math.abs(position));
                view.setScaleX(scaleFactor);
                view.setScaleY(scaleFactor);        } else { // (1,+Infinity]
                // This page is way off-screen to the right.
                view.setAlpha(0);
            }
        }
    }
      

  2.   


    非常感谢你的回答! 原来还可以这样调整ViewPager切换动画!
    这里呢,我只是希望让ViewPager里面的每个Page里的widget动画效果,
    并且随着拉伸的程度,对应改变动画的位置!我的大概做法是: 
    1) 重写ViewPager控件,在onPageScrolled方法里回调接口,返回滑动的方向,距离,百分比等.
    2) 然后通过滑动的百分比,计算出动画的执行完成度,播放对应的动画,然后保存一个临时动画点.
      

  3.   


    非常感谢你的回答! 原来还可以这样调整ViewPager切换动画!
    这里呢,我只是希望让ViewPager里面的每个Page里的widget动画效果,
    并且随着拉伸的程度,对应改变动画的位置!我的大概做法是: 
    1) 重写ViewPager控件,在onPageScrolled方法里回调接口,返回滑动的方向,距离,百分比等.
    2) 然后通过滑动的百分比,计算出动画的执行完成度,播放对应的动画,然后保存一个临时动画点.了然,呵呵。
      

  4.   

    这里的0,1指的是滑动的距离比例么
    可以这么理解。
    The position parameter indicates where a given page is located relative to the center of the screen. It is a dynamic property that changes as the user scrolls through the pages. When a page fills the screen, its position value is 0. When a page is drawn just off the right side of the screen, its position value is 1. If the user scrolls halfway between pages one and two, page one has a position of -0.5 and page two has a position of 0.5. Based on the position of the pages on the screen, you can create custom slide animations by setting page properties with methods such as setAlpha(), setTranslationX(), or setScaleY().
      

  5.   

    这里的0,1指的是滑动的距离比例么
    可以这么理解。
    The position parameter indicates where a given page is located relative to the center of the screen. It is a dynamic property that changes as the user scrolls through the pages. When a page fills the screen, its position value is 0. When a page is drawn just off the right side of the screen, its position value is 1. If the user scrolls halfway between pages one and two, page one has a position of -0.5 and page two has a position of 0.5. Based on the position of the pages on the screen, you can create custom slide animations by setting page properties with methods such as setAlpha(), setTranslationX(), or setScaleY().嗯  很清晰明了  这样的话  设置动画很方便
      

  6.   

    问一下,为什么当我设置v.setScaleX(scale);v.setScaleY(scale);的时候,设置完之后拖动它对他进行缩放时,图片会闪呢