机器人 - 获取视图的可见区域? [英] Android - Get the visible area of a view?

查看:193
本文介绍了机器人 - 获取视图的可见区域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个Android 查看正在被部分地被另一个屏蔽查看。举例来说,假设屏蔽观点有它的中心一个透明的矩形窗口,而我的观点是围绕窗口,并具有尺寸大于窗口的尺寸较大的下方。在这种情况下,视图的一些矩形部分将可见,其余被遮盖的掩模。

Suppose I have an Android View that is being partially masked by another View. For instance, imagine that the masking view has a transparent rectangular "window" in the center of it, and my view is centered beneath the window and possessing dimensions that are larger than the dimensions of the window. In such a case, some rectangular portion of the view will be visible, with the rest being obscured by the mask.

所以我的问题是,有没有简单的方法以检索的位置,可见区域的尺寸的没有的具有任何访问掩蔽​​视图本身(所以不知道有多大的面具的窗口本身就是)?

So my question is, is there any straightforward way to retrive the position and dimensions of the visible area without having any access to the masking view itself (so without knowing how big the mask's "window" itself is)?

我打过电话 getLocalVisibleRect(),听起来很有希望,但似乎只返回该视图的布局矩形和的不是的的是矩形实际上可见。

I tried calling getLocalVisibleRect(), which sounded promising, but that only seems to return the view's layout rectangle and not the rectangle that is actually visible.

推荐答案

这是pretty的后来者,但我怀疑 getGlobalVisibleRect 你想要做什么

This is pretty late to the game, but I suspect that getGlobalVisibleRect does what you want.

这篇关于机器人 - 获取视图的可见区域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆