Android:ViewPager 切换动画效果

ViewPager 可以设置不同页面切换效果,通过方法 setPageTransformer(boolean reverseDrawingOrder, PageTransformer transformer) 实现。

其中第二个参数 PageTransformer 是关键

PageTransformer 是一个接口,只有一个方法 transformPage() ,参数:第一个是view,第二个是position

 1     public interface PageTransformer {
 2         /**
 3          * Apply a property transformation to the given page.
 4          *
 5          * @param page Apply the transformation to this page
 6          * @param position Position of page relative to the current front-and-center
 7          *                 position of the pager. 0 is front and center. 1 is one full
 8          *                 page position to the right, and -1 is one page position to the left.
 9          */
10         public void transformPage(View page, float position);
11     }

position的可能性的值有,其实从官方示例的注释就能看出:
[-Infinity,-1) 已经看不到了
(1,+Infinity] 已经看不到了
[-1,1]
重点看[-1,1]这个区间 , 其他两个的View都已经看不到了

ViewPage 有三个页面,当前显示的页面,缓存左边和右边页面,左边和右边的页面是看不到的。

详情查看:http://blog.csdn.net/lmj623565791/article/details/40411921/

posted @ 2016-11-25 14:34  熠然  阅读(1646)  评论(0编辑  收藏  举报