Android中View跟随手指滑动效果的实例代码
发布时间:2020-09-21 08:03:14
来源:脚本之家
阅读:127
作者:meetings
本文讲述了Android中View跟随手指滑动效果的实例代码。分享给大家供大家参考,具体如下:
1、android View 主要6种滑动方法,分别是
layout()
offsetLeftAndRight()和offsetTopAndBottom()
LayoutParams
scrollBy()和 scrollTo()
Scroller
动画
2、实现效果图
3、自定义中使用layout()方法实习view的滑动
public class MoveView extends View {
private int lastX, lastY;
public MoveView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public MoveView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(contex