什么是android相当于UIView的convertRectconvertPoint函数?

什么是android相当于UIView的convertRectconvertPoint函数?,第1张

概述UIView具有以下内容: - convertPoint:toView:- convertPoint:fromView:- convertRect:toView:- convertRect:fromView: 什么是Android相当的?更一般地说,给定两个视图,我如何得到第二个View的rect在第一个坐标系? 我不认为这是sdk的一部分,但是您似乎可以使用getLocationOnScr UIVIEw具有以下内容:
- convertPoint:toVIEw:- convertPoint:fromVIEw:- convertRect:toVIEw:- convertRect:fromVIEw:

什么是AndroID相当的?更一般地说,给定两个视图,我如何得到第二个VIEw的rect在第一个坐标系?

解决方法 我不认为这是sdk的一部分,但是您似乎可以使用getLocationOnScreen轻松编写自己的实现:
public static Point convertPoint(Point fromPoint,VIEw fromVIEw,VIEw toVIEw){    int[] fromCoord = new int[2];    int[] toCoord = new int[2];    fromVIEw.getLocationOnScreen(fromCoord);    toVIEw.getLocationOnScreen(toCoord);    Point topoint = new Point(fromCoord[0] - toCoord[0] + fromPoint.x,fromCoord[1] - toCoord[1] + fromPoint.y);    return topoint;}
public static Rect convertRect(Rect fromrect,VIEw toVIEw){    int[] fromCoord = new int[2];    int[] toCoord = new int[2];    fromVIEw.getLocationOnScreen(fromCoord);    toVIEw.getLocationOnScreen(toCoord);    int xShift = fromCoord[0] - toCoord[0];    int yShift = fromCoord[1] - toCoord[1];    Rect toRect = new Rect(fromrect.left + xShift,fromrect.top + yShift,fromrect.right + xShift,fromrect.bottom + yShift);    return toRect;}
总结

以上是内存溢出为你收集整理的什么是android相当于UIView的convertRect / convertPoint函数?全部内容,希望文章能够帮你解决什么是android相当于UIView的convertRect / convertPoint函数?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1133804.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存