您可以使用 mScrollX 和 mScrollY 来计算画布的哪个可见部分需要重新绘制。
/**
* The offset, in pixels, by which the content of this view is scrolled
* vertically.
* {@hide}
*/
@ViewDebug.ExportedProperty
protected int mScrollY;
/**
* The left padding in pixels, that is the distance in pixels between the
* left edge of this view and the left edge of its content.
* {@hide}
*/
@ViewDebug.ExportedProperty
protected int mPaddingLeft;
/**
* The right padding in pixels, that is the distance in pixels between the
* right edge of this view and the right edge of its content.
* {@hide}
*/
@ViewDebug.ExportedProperty
protected int mPaddingRight;
/**
* The top padding in pixels, that is the distance in pixels between the
* top edge of this view and the top edge of its content.
* {@hide}
*/
@ViewDebug.ExportedProperty
protected int mPaddingTop;
/**
* The bottom padding in pixels, that is the distance in pixels between the
* bottom edge of this view and the bottom edge of its content.
* {@hide}
*/
@ViewDebug.ExportedProperty
protected int mPaddingBottom;