在APP的ViewPager引导页面中, 我们通常可以看到底部有小圆点显示当前是第几页, 我们来试一下这个效果是怎么实现的, 效果图如下:
{% cq %}
代码是最为耐心、最能忍耐和最令人愉快的伙伴,在任何艰难困苦的时刻,它都不会抛弃你。
{% endcq %}
基础配置
首先要创建出一个滑动页面,可以阅读我以前的文章, 也可以直接读以下文档.
创建适配器控件
在布局中.添加 viewpager控件
, 并在MainActivity中 绑定控件
.
- 布局中:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context="com.example.dell.lunbo.MainActivity">
<android.support.v4.view.ViewPager
android:id="@+id/main_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout
android:id="@+id/main_linear"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:gravity="center"
android:orientation="horizontal" />
</RelativeLayout>
- MainActivity中:
import android.os.Bundle;