我正在按照以下方式更改图像视图的左边距:
ViewGroup.MarginLayoutParams layoutParams = (MarginLayoutParams) image.getLayoutParams ();
layoutParams.leftMargin = VALUE;
image.setLayoutParams ( layoutParams );
我希望边距的改变能够带有动画效果。有什么线索吗?
我尝试过的:
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat ( image , "x" , VALUE);
objectAnimator.start();
这种方法的移动图片效果非常完美,但是layoutParams.leftMargin的值保持不变!!因此我无法使用这种方法,因为如果我在使用值为100的objectAnimator后尝试将layoutParams.leftMargin的值更改为100,那么应用的值就不正确(200被应用而不是100),即使我以以下方式设置左边距,objectAnimator的效果仍然存在:
layoutParams.leftMargin = 100;