ViewPager实现带有动画的引导页,供大家参考,具体内容如下

好了,又到我们学习基础控件的时候了,其实引导页很简单,就是五张图片而已
一、ViewPager实现传统的引导页
传统的ViewPager实现引导页和ListView是一样道理的,只是把ListView的Item换成图片,把BaseAdapter换成PagerAdapter,我们先来看下传统引导页的效果图
步骤一:编写xml文件
既然用到的是ViewPager,那么xml文件就必须要有ViewPager,细心的你,可能会发现最后一页还有个按钮的出现,没错,xml文件中也要有个按钮
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="@+id/vp_guide"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<Button
android:id="@+id/bt_main"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:layout_marginBottom="50dp"
android:background="@color/colorPrimary"
android:padding="6dp"
android:text="立即开启"
android:textColor="#fff"
android:textSize="16dp"
android:visibility="gone" />
</RelativeLayout>