使用stackView,表现出view堆叠的效果,可以拖动,也可以触发事件切换
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> <StackView android:id="@+id/mStackView" android:layout_width="match_parent" android:layout_height="wrap_content" android:loopViews="true" /> <LinearLayout android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="上一个" android:onClick="prev"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="下一个" android:onClick="next"/> </LinearLayout> </LinearLayout>