通过此方法使View位置发生偏移,达到margin的作用却又不改变View的getLeft()的值。

恢复方法是setTranslationX(0),而不是上一次偏移量的相反数。

不过,通过getLocationInWindow(), getLocationOnScreen()获取到的位置是发生变化的,因此才能看到View的移动。

 

参考:Android动画精讲一:从setTranslationX谈属性动画和view动画的区别

相关文章:

  • 2021-10-23
  • 2022-03-03
  • 2022-12-23
  • 2022-12-23
  • 2021-05-31
  • 2021-09-02
  • 2021-07-15
  • 2021-05-02
猜你喜欢
  • 2021-09-05
  • 2021-07-29
  • 2021-05-18
  • 2021-07-03
相关资源
相似解决方案