一、layout(int l, int t, int r, int b)
layout(getLeft()+ 200,getTop()+ 400,getRight()+ 200,getBottom()+ 400);
移动后getLeft()值改变
二、offsetLeftAndRight(int offset)和offsetTopAndBottom(int offset)
offsetLeftAndRight(200);
offsetTopAndBottom(400);
移动后getLeft()值改变
三、修改LayoutParams
ViewGroup.MarginLayoutParams lp=(ViewGroup.MarginLayoutParams)getLayoutParams();
lp.leftMargin= getLeft()+ 200;
lp.topMargin= getTop()+ 400;
setLayoutParams(lp);
移动后getLeft()值不改变
四、scrollTo(int x, int y)和scrollBy(int x, int y)
((View)getParent()).scrollTo(-200,-400);
或者
((View)getParent()).scrollBy(-200,-400);
移动后getLeft()值不改变
五、setTranslationX(float translationX)和setTranslationY(float translationY)
setTranslationX(200);
setTranslationY(400)
移动后getLeft()值不改变
六、属性动画
AnimatorSet set= newAnimatorSet();
set.playTogether(ObjectAnimator.ofFloat(this,"translationX",200), ObjectAnimator.ofFloat(this,"translationY",400));
set.start();
移动后getLeft()值不改变
七、位移动画
TranslateAnimation anim= newTranslateAnimation(0,200,0,400);
anim.setFillAfter(true);
startAnimation(anim);
移动后getLeft值不改变

919

被折叠的 条评论
为什么被折叠?



