Android ViewPagerIndicator指示器

本文介绍了如何在Android项目中实现ViewPagerIndicator指示器,包括导入ViewPagerIndicator库,设置布局,自定义样式以及解决部分模拟器上的BUG。通过设置布局文件、ViewPager的适配器,调整样式以及同步ViewPagerIndicator和ViewPager的滑动,实现指示器的功能。
摘要由CSDN通过智能技术生成

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

兴帅_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值