【发布时间】:2020-07-07 12:21:28
【问题描述】:
Docs 说Radius value that specifies the ripple radius should be computed based on the size of the ripple's container. 但我找不到它计算的确切位置。我试图用调试器把它弄出来,但没有成功。
你能告诉我这个计算是在哪里进行的吗?
【问题讨论】:
Docs 说Radius value that specifies the ripple radius should be computed based on the size of the ripple's container. 但我找不到它计算的确切位置。我试图用调试器把它弄出来,但没有成功。
你能告诉我这个计算是在哪里进行的吗?
【问题讨论】:
我找到了。该计算在RippleComponent 类的setup(float, int) 方法中执行:
public final void setup(float maxRadius, int densityDpi) {
if (maxRadius >= 0) {
mHasMaxRadius = true;
mTargetRadius = maxRadius;
} else {
mTargetRadius = getTargetRadius(mBounds); // this place!
}
mDensityScale = densityDpi * DisplayMetrics.DENSITY_DEFAULT_SCALE;
onTargetRadiusChanged(mTargetRadius);
}
正是这个类处理涟漪和焦点状态常见的大小和位置。 RippleState 和 RippleDrawable 都不是。
【讨论】: