Reputation: 16385
I have a requirement where i have to place a set of Fragments in a Swipe View. Underneath the swipe view i also want a Page indictor ? Is there any open source libraries that support this ?
Kind Regards
Upvotes: 1
Views: 6262
Reputation: 2030
I'm using this:
Layout:
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/icnSecond"
android:background="#000000" />
<ImageView
android:id="@+id/icnSecond"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:src="@drawable/dot" />
<ImageView
android:id="@+id/icnThird"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="@+id/icnSecond"
android:src="@drawable/dot />
<ImageView
android:id="@+id/icnFirst"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="@+id/icnSecond"
android:src="@drawable/dot" />
Activity:
mPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
if (position == 0) {
icnFirst.setAlpha(255);
icnSecond.setAlpha(70);
icnThird.setAlpha(70);
}
if (position == 1) {
icnFirst.setAlpha(70);
icnSecond.setAlpha(255);
icnThird.setAlpha(70);
startMoving();
}
if (position == 2) {
icnFirst.setAlpha(70);
icnSecond.setAlpha(70);
icnThird.setAlpha(255);
}
}
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {}
@Override
public void onPageScrollStateChanged(int state) {}
});
Upvotes: 1
Reputation: 6027
This is one of the best libraries.
Library: jwVPIndicatorLib
Tutorial: check this
Upvotes: 1