View的位置主要由它的四个顶点来决定,即它的四个属性:top、left、right、bottom,分别表 示View左上角的坐标点(top,left)以及右下角的坐标点(right,bottom)。同时,我们可以 得到View的大小:
width = right - left
height = bottom - top
而这四个参数可以由以下方式获取:
Left = getLeft();Right = getRight();Top = getTop();
Bottom = getBottom(); Android3.0后,View增加了x、y、translationX和translationY这几个参数。其中x和y是 View左上角的坐标,而translationX和translationY是View左上角相对于容器的偏移量。 他们之间的换算关系如下: x = left + translationX; y = top + translationY; 注意:View在平移的过程中,top和left不会改变,改变的是x、y、translationX和 translationY。
ObjectAnimator oa = ObjectAnimator
.ofFloat(tvShow,
"translationX",
200)
oa
.setDuration(
2000)
oa
.start()