1,实现效果
2,导入
【1】ViewPagerIndicator项目导入
-
自己项目下添加依赖
compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
-
整体项目添加 maven
allprojects {
repositories {
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
}
}
3,简单使用
【1】布局文件中添加,必须和viewpager 一起使用
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical" >
<com.viewpagerindicator.TabPageIndicator
android:id="@+id/indicator"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/vp_news"
/>
</Line