
我在另一个尺寸的屏幕上绘制视图时遇到问题!
我需要有两个VIEw类型参数的方法.如果第一个视图在第二个视图上重叠,则返回true,而在另一个视图中则返回false
和
解决方法:
您还可以使用Rect.intersect()来查找重叠视图.
int[] firstposition = new int[2]; int[] secondposition = new int[2]; firstVIEw.getLocationOnScreen(firstposition); secondVIEw.getLocationOnScreen(secondposition); // Rect constructor parameters: left, top, right, bottom Rect rectFirstVIEw = new Rect(firstposition[0], firstposition[1], firstposition[0] + firstVIEw.getMeasureDWIDth(), firstposition[1] + firstVIEw.getMeasuredHeight()); Rect rectSecondVIEw = new Rect(secondposition[0], secondposition[1], secondposition[0] + secondVIEw.getMeasureDWIDth(), secondposition[1] + secondVIEw.getMeasuredHeight()); return rectFirstVIEw.intersect(rectSecondVIEw); 总结 以上是内存溢出为你收集整理的android – 检测视图是否重叠全部内容,希望文章能够帮你解决android – 检测视图是否重叠所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)