AndroidDev
AndroidDev

Reputation: 16385

Android Page indicator with swipe

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

Answers (4)

The Badak
The Badak

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

TheFlash
TheFlash

Reputation: 6027

This is one of the best libraries.

Library: jwVPIndicatorLib

Tutorial: check this

Upvotes: 1

Diego Palomar
Diego Palomar

Reputation: 7061

What you are looking for is Android ViewPagerIndicator.

Upvotes: 0

Shadow
Shadow

Reputation: 6899

Why can't you use Action bar sherlock view pager library?

https://github.com/JakeWharton/Android-ViewPagerIndicator

Upvotes: 1

Related Questions