先来看看效果图:
看看Xml布局文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<!--自定义WiewPager-->
<com.example.admin.viewpagerindicator.ViewPagerIndicator
android:id="@+id/view_indicator"
android:layout_width="match_parent"
android:layout_height="45dp"
android:orientation="horizontal"
android:background="#666666"
app:visible_count="5">
</com.example.admin.viewpagerindicator.ViewPagerIndicator>
<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</android.support.v4.view.ViewPager>
</LinearLayout>
看看java代码:
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.grap