Android 开发者官方教程中的以下代码是什么,Using ViewPager for Screen Slides ?
public class ZoomOutPageTransformer implements ViewPager.PageTransformer {
//...
public void transformPage(View view, float position) {
//...
if (position < -1) { // **[-Infinity,-1)
//...
} else if (position <= 1) { // [-1,1]
//...
} else { // (1,+Infinity]
//...
}
}
}
最佳答案
这些评论的意思或多或少是:
if (position < -1) { // here go all 'position' values lesser than -1
//...
} else if (position <= 1) { // 'position' in range from -1 to 1, including both -1 and 1
//...
} else { // and then all 'position' values greater than 1 go here
//...
}
如果您正在寻找 Android 中 Float
类型的“无穷大”值,则有 Float.NEGATIVE_INFINITY
和 Float.POSITIVE_INFINITY
值代表他们。
关于安卓开发教程 : What is `Infinity` in ViewPager Sample?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32202054/