Từ JavaDoc of getGlobalVisibleRect:
/**
* If some part of this view is not clipped by any of its parents, then
* return that area in r in global (root) coordinates. To convert r to local
* coordinates (without taking possible View rotations into account), offset
* it by -globalOffset (e.g. r.offset(-globalOffset.x, -globalOffset.y)).
* If the view is completely clipped or translated out, return false.
*
* @param r If true is returned, r holds the global coordinates of the
* visible portion of this view.
* @param globalOffset If true is returned, globalOffset holds the dx,dy
* between this view and its root. globalOffet may be null.
* @return true if r is non-empty (i.e. part of the view is visible at the
* root level.
*/
getLocalVisibleRect gọi getGlobalVisibleRect và sau đó làm cho nó địa phương theo đề nghị:
r.offset(-offset.x, -offset.y); // make r local`
Vì vậy:
- Nó không trả lại một hình chữ nhật, nó trả về một boolean. Nhưng nó có thể thiết lập các thông số của một hình chữ nhật bạn vượt qua, và đó phải là một hình chữ nhật android.graphics.Rect;
- Hình chữ nhật r sẽ được lấp đầy với các tọa độ cục bộ;
- Tôi không chắc chắn nhưng tôi nghĩ rằng đó là tương tự cho visibile và quan điểm vô hình, trong khi nó nên return false cho ý kiến với
visibility="gone"
Tôi tạo ra một vấn đề đối với tài liệu hướng dẫn. Bạn có thể theo dõi tại đây https://issuetracker.google.com/issues/73832083 BTW bạn cũng có thể tạo ra vấn đề cho tài liệu nếu bạn thấy điều gì đó thiếu hoặc không phù hợp. Có phần 'support' ở cuối trang. Và ở đó bạn có thể chọn 'Báo cáo tài liệu lỗi'. –