android中View的移动分为两种,View位置的移动和View内容的移动。
一、 View位置移动的方法
- 修改mTranslationX或mTranslationY的值
- 设置MarginLayoutParams的margin值
- 设置ViewGroup.LayoutParams的width或height
- 设置View的mLeft、mRight、mTop、mBottom
- 对Matrix进行操作
二、View内容移动的方法,View内容移动针对的是有子View的View即ViewGroup的内容移动
- scrollBy()
- scrollTo()
- 通过Scroller平滑滑动
- setPadding()