解决方案 »
- 请问如何查xml布局文件的文档?
- 如何将camera settings背景设为透明
- androidGridView --九宫格显示问题
- android桌面快捷方式问题,在线等!!!
- android系统,如何画信号强度界面(如图)
- 计算日期的方法
- MainActivity中调用fragement实现导航的问题????
- Android java开发能用javax.ws.rs.client吗?
- Android中Eclipse错误You must restart adb and Eclipse.
- Android stutio 无法为Button添加id问题
- listView中的checkbox全选问题
- 短信(Mms)notification下拉事件
以下代码来源于官方网站: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);
}
}
}
非常感谢你的回答! 原来还可以这样调整ViewPager切换动画!
这里呢,我只是希望让ViewPager里面的每个Page里的widget动画效果,
并且随着拉伸的程度,对应改变动画的位置!我的大概做法是:
1) 重写ViewPager控件,在onPageScrolled方法里回调接口,返回滑动的方向,距离,百分比等.
2) 然后通过滑动的百分比,计算出动画的执行完成度,播放对应的动画,然后保存一个临时动画点.
非常感谢你的回答! 原来还可以这样调整ViewPager切换动画!
这里呢,我只是希望让ViewPager里面的每个Page里的widget动画效果,
并且随着拉伸的程度,对应改变动画的位置!我的大概做法是:
1) 重写ViewPager控件,在onPageScrolled方法里回调接口,返回滑动的方向,距离,百分比等.
2) 然后通过滑动的百分比,计算出动画的执行完成度,播放对应的动画,然后保存一个临时动画点.了然,呵呵。
可以这么理解。
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().
可以这么理解。
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().嗯 很清晰明了 这样的话 设置动画很方便