Android 何时使用OffsetDescendarElectToMyCoords?
我在看一个在线教程,他用了OffsetDescentRoctTomyCoords。我研究了很多,但没有找到任何令人满意的解释。我参考了文件,上面写着 “将子体坐标空间中的矩形偏移到我们的坐标空间” 我不明白。。我们的坐标空间是什么Android 何时使用OffsetDescendarElectToMyCoords?,android,android-view,Android,Android View,我在看一个在线教程,他用了OffsetDescentRoctTomyCoords。我研究了很多,但没有找到任何令人满意的解释。我参考了文件,上面写着 “将子体坐标空间中的矩形偏移到我们的坐标空间” 我不明白。。我们的坐标空间是什么 非常感谢您的帮助。假设我们有如下布局层次结构: private int getTopWithinGrandParent(View child) { child.getDrawingRect(mTempRect); mGrandParent.offse
非常感谢您的帮助。假设我们有如下布局层次结构:
private int getTopWithinGrandParent(View child) {
child.getDrawingRect(mTempRect);
mGrandParent.offsetDescendantRectToMyCoords(child, mTempRect);
return mTempRect.top;
}
祖父母/父母/子女
每个层次结构级别都有10dp布局填充。
如果需要计算子顶部边缘和祖父母顶部边缘之间的空间。然后你可以这样做:
private int getTopWithinGrandParent(View child) {
child.getDrawingRect(mTempRect);
mGrandParent.offsetDescendantRectToMyCoords(child, mTempRect);
return mTempRect.top;
}
当您有两个以上的嵌套视图(3个或更多)并且要计算后代视图相对于父代或其他更高级别的父代的偏移量(但对于直接父代,不需要调用此方法)时,将使用OffsetDegeneratorElectToMyCoords方法