Material-ViewPagerIndicator
介绍:
一个简单易用的ViewPagerIndicator,什么都不用做,直接把它添加给ViewPager就可以了。
运行效果:
使用说明:
xml
<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignWithParentIfMissing="true">
<!-- Add as a direct child of your ViewPager -->
<com.itsronald.widget.ViewPagerIndicator
android:id="@+id/view_pager_indicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:gravity="center_vertical"/>
</android.support.v4.view.ViewPager>
或者在代码里这样做
import android.support.v4.view.ViewPager;import android.view.Gravity;import android.view.ViewGroup.LayoutParams;import com.itsronald.widget.ViewPagerIndicator;...ViewPager viewPager = ...;final ViewPager.LayoutParams layoutParams = new ViewPager.LayoutParams();
layoutParams.width = LayoutParams.MATCH_PARENT;
layoutParams.height = LayoutParams.WRAP_CONTENT;
layoutParams.gravity = Gravity.BOTTOM;final ViewPagerIndicator viewPagerIndicator = new ViewPagerIndicator(context);
viewPager.addView(viewPagerIndicator, layoutParams);
下载
Material-ViewPagerIndicator 可以在 JitPack.io上获取。
Gradle
把JitPack添加到你的maven仓库:
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
在app依赖中添加Material-ViewPagerIndicator:
dependencies {
// x.y.z is the latest release version number.
compile 'com.github.ronaldsmartin:Material-ViewPagerIndicator:x.y.z'
}
已下载
0