先前在写一个测试项目的时候用到了页面切换之间的效果,用的是GestureDetector手势识别器实现的,最后交由onTouchEvent方法来托管手势识别器实现页面的左右滑动,实现起来也很简单。
以下是实现步骤:
首先是两个活动的xml文件,这里仅作简单示例,因为两个文件几乎相同,所以贴上第一个的。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff88EE" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="我是第一个页面,快往左滑我到第二个页面" />
&l