Android View的几个位置坐标关系

1. View的边界,left, top, right, bottom(即左上右下),这些值都是相对View的父容器说的;动画

2. View的x, translationX, y, translationY, translationX/Y表示相对于left,top的偏移,通常用在View的translation动画中,io

有以下的关系:x = left + translationX, y = top + translationY;容器

3. View的mScrollX,  mScrollY是指View的边界相对于View内容的距离,好比有个LinearLayout container1,其中的紧接着的childrenscroll

是btn1,这时若是调用container1.scrollBy(0, 30),那么container1的4个边界是永远不会变的,变的是container1的内容,也就是btn1top

的坐标会变,btn1的top如今会减小30个像素;co

4. View的offsetTopAndBottom直接改变的是top, bottom, 至关于在parent中上下平移View的位置;offsetLeftAndRight直接改变的是container

left, right, 至关于在parent中左右平移View的位置;View的边界直接发生了变化,又由于View和他的子View的相对位置没变,因此他的像素

子View的边界也跟着变化了。

相关文章
相关标签/搜索