【问题标题】:Android: UI: using bounderiesAndroid:UI:使用边界
【发布时间】:2012-04-27 21:28:20
【问题描述】:
【问题讨论】:
标签:
android
user-interface
boundary
【解决方案1】:
我会这样做:
- 扩展您选择的 ScrollView
- 在构造函数中调用
setStaticTransformationsEnabled(true);
- 覆盖
onTouchEvent(MotionEvent ev) 以跟踪手指的位置
- 覆盖
getChildStaticTransformation(View child, Transformation t)
- 在该函数内部使用Camera 类来创建3D 变换矩阵。像围绕 x 轴旋转的东西,旋转的中心是滚动视图的中心。旋转角度应取决于子项的滚动位置和当前手指位置。
编辑:现在我考虑的时间更长了,你应该做一些不同的事情。
- 不要覆盖
getChildStaticTransformation(View child, Transformation t),而是覆盖drawChild(Canvas canvas, View child, long drawingTime)。
这允许您使用绘图缓存 API。 (我的第一个链接中的示例)。这意味着首先将子对象渲染为位图,从而提高绘图性能并允许您将此线性蓝色应用于视图的透明渐变
您可以查看here 或here 了解如何使用相机的示例。
This 是一个带有过度滚动弹跳效果的项目。
为了使过度滚动效果更酷,您应该在用户松开手指时使用动画。因为我非常喜欢新的 android 动画框架,所以我会使用 nine old androids。
我想对于一个有经验的安卓程序员来说,正确地实现这个效果至少需要 1-2 天。