检测,如果观点是重叠 [英] detect if views are overlapping
本文介绍了检测,如果观点是重叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有问题,对其他尺寸的屏幕绘制的意见! 我需要的方法,该方法具有景观类型两个参数。并返回true,如果对第二种观点第一种观点的重叠,而假的另一种情况!
I have problem with drawing views on another size screens! I need method which has two parameters of View type. And return true if first view overlapping on second view, and false in another case!
和
推荐答案
狂暴感谢您的帮助! 一些实验后,我写的方法,该方法检测视图重叠或不适合我的情况!
Berserk thanks you for help! After some experiments I wrote method which detect view is overlapped or not for my case!
private boolean isViewOverlapping(View firstView, View secondView) {
int[] firstPosition = new int[2];
int[] secondPosition = new int[2];
firstView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
firstView.getLocationOnScreen(firstPosition);
secondView.getLocationOnScreen(secondPosition);
int r = firstView.getMeasuredWidth() + firstPosition[0];
int l = secondPosition[0];
return r >= l && (r != 0 && l != 0);
}
这篇关于检测,如果观点是重叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文