千变万化的ViewPager切换动画(三、自定义ViewPager的实现方法)

来源:互联网 发布:大量淘宝账号 编辑:程序博客网 时间:2024/06/07 09:25

关于这学习的内容,以小编目前的功力还不能用文字叙述清楚,所以,我推荐直接去看视频容易理解一些。

视频地址:http://www.imooc.com/video/6101

当然,也可以去细细品味一下鸿洋大神的博客:http://blog.csdn.net/lmj623565791/article/details/38026503


关于这次涉及到的ViewPager中的onPageScrolled方法是关键,这里贴出该方法的注释。

/**     * This method will be invoked when the current page is scrolled, either as part     * of a programmatically initiated smooth scroll or a user initiated touch scroll.     * If you override this method you must call through to the superclass implementation     * (e.g. super.onPageScrolled(position, offset, offsetPixels)) before onPageScrolled     * returns.     *     * @param position Position index of the first page currently being displayed.     *                 Page position+1 will be visible if positionOffset is nonzero.     * @param offset Value from [0, 1) indicating the offset from the page at position.     * @param offsetPixels Value in pixels indicating the offset from position.     */    @Override    protected void onPageScrolled(int position, float offset, int offsetPixels){}

还有,在最后也提到了一个开源项目JazzyViewPager.java,它的原理也和本次所要学习的内容差不多,不过它实现了12种动画效果,可以很方便的直接拿来用。

0 0