Android RippleForeground 有界模式实现
Android RippleForeground bounded mode implementation
我正在阅读 RippleDrawable
和 RippleForeground(软件渲染部分)的实现,我已经知道有界意味着波纹有一个掩码。
但我仍然对实施的一些要点感到困惑:
为什么实现说 "Bounded ripples don't have enter animations" 并且只是跳过它的进入动画?在这种情况下如何启动波纹动画(如果用户没有释放他的触摸所以没有触发退出)?
@Override
protected Animator createSoftwareEnter(boolean fast) {
// Bounded ripples don't have enter animations.
if (mIsBounded) {
return null;
}
...
}
为什么实施选择了 nearly constant value (and why is that random()
) for mBoundedRadius
and mTargetRadius
?如果用 ColorDrawable
屏蔽的视图大于该尺寸,它能正常工作吗?
public RippleForeground(RippleDrawable owner, Rect bounds, float startingX, float startingY,
boolean isBounded) {
...
if (isBounded) {
mBoundedRadius = MAX_BOUNDED_RADIUS * 0.9f
+ (float) (MAX_BOUNDED_RADIUS * Math.random() * 0.1);
}
...
}
...
private void computeBoundedTargetValues() {
...
mTargetRadius = mBoundedRadius;
}
对于第一个问题,我通过深入研究提交历史并尝试使用新的 Marshmallow 图像自行找到了答案。答案很简单:
他们移除了有界RippleDrawable
触摸时的(前景)波纹,但没有为无界移除,故意留下这种不一致。
我刚刚在来自 Android SDK 的 Marshmallow 图像上进行了测试。它被移除了,更糟糕的是,他们在用户第一次触摸屏幕的地方而不是他们的手指离开屏幕的地方留下了退出波纹。
我无法理解这个设计决定,因为它对我来说更像是一种倒退,而不是一种改进,但正如在提交日志中,他们认为他们做了 implement bounded ripple animation,而不是删除它。
但是对于第二个问题,我还没有得到答案
我正在阅读 RippleDrawable
和 RippleForeground(软件渲染部分)的实现,我已经知道有界意味着波纹有一个掩码。
但我仍然对实施的一些要点感到困惑:
为什么实现说 "Bounded ripples don't have enter animations" 并且只是跳过它的进入动画?在这种情况下如何启动波纹动画(如果用户没有释放他的触摸所以没有触发退出)?
@Override protected Animator createSoftwareEnter(boolean fast) { // Bounded ripples don't have enter animations. if (mIsBounded) { return null; } ... }
为什么实施选择了 nearly constant value (and why is that
random()
) formBoundedRadius
andmTargetRadius
?如果用ColorDrawable
屏蔽的视图大于该尺寸,它能正常工作吗?public RippleForeground(RippleDrawable owner, Rect bounds, float startingX, float startingY, boolean isBounded) { ... if (isBounded) { mBoundedRadius = MAX_BOUNDED_RADIUS * 0.9f + (float) (MAX_BOUNDED_RADIUS * Math.random() * 0.1); } ... } ... private void computeBoundedTargetValues() { ... mTargetRadius = mBoundedRadius; }
对于第一个问题,我通过深入研究提交历史并尝试使用新的 Marshmallow 图像自行找到了答案。答案很简单:
他们移除了有界RippleDrawable
触摸时的(前景)波纹,但没有为无界移除,故意留下这种不一致。
我刚刚在来自 Android SDK 的 Marshmallow 图像上进行了测试。它被移除了,更糟糕的是,他们在用户第一次触摸屏幕的地方而不是他们的手指离开屏幕的地方留下了退出波纹。
我无法理解这个设计决定,因为它对我来说更像是一种倒退,而不是一种改进,但正如在提交日志中,他们认为他们做了 implement bounded ripple animation,而不是删除它。
但是对于第二个问题,我还没有得到答案