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()
Android视图移动详解
本文详细介绍了Android中视图移动的两种方式:视图位置移动和视图内容移动。对于视图位置移动,可以通过修改mTranslationX/mTranslationY、设置布局参数等方法实现;对于视图内容移动,则主要通过scrollBy、scrollTo等方法完成。
598

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



