- 滑动实现的方式有至少三种:scrollTo/scrollBy、动画以及改变布局参数。动画实现滑动比较方便,操作简单,主要适用于没有交互的View
- demo成品
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200717220310962.png)
*在这个demo中使用到了类 ViewHelper,使用这个类需要导入该类的jar包,下面贴一个能下载jar包的地址,需要不同的包可以载里面下载导入
- layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="@+id/drag_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="拖拽我呀"
android:layout_centerInParent="true"/