美文网首页
View的位置参数

View的位置参数

作者: YangGui | 来源:发表于2017-02-22 14:30 被阅读0次

Android开发艺术探索笔记

  1. top left right bottom 标识View的四个顶点。
    这四个点的坐标值是相对于其父控件的,是一个相对值。对应了View类的mLeft,mRight,mTop,mBottom四个成员变量。
    width = right - left;
    height = bottom- top;
    获取方式:
    Left = getLeft();
    Right = getRight();
    Top = getTop();
    Bottom = getBottom();

  2. x y translationX translationY
    x,y是View左上角的坐标。
    translationX, translationY是View左上角相对于父控件的偏移量。
    这四个值也是相对父控件的相对坐标值。

  3. 参数的相对关系
    top left right bottom是随View的layout后就确定不变的原始坐标信息。x y translationX translationY是标识View显示位置的。
    x = left + translationX
    y = top + translationY

View位置的参数.png

相关文章

网友评论

      本文标题:View的位置参数

      本文链接:https://www.haomeiwen.com/subject/jlcmwttx.html