Android scrolling paging with page indicator

I am going to finish my first Android application, and I have some questions that I could not find the answer to.

I would like to use a horizontal scroller to display multiple images. To do this, I need two things:

  • Paging is enabled so that the user can see the images one by one in the scroller.
  • Some kind of indicator to show me the index of the image currently being displayed.

If I manage to swap, I could display the text, for example, 1/4 (2/4, etc.), if I had 4 photos, but this is not very nice. I would like to have something similar to an iPhone with gray / white dots. Is there something similar, or would I have to implement it by adding content at runtime? (adding images according to the number of images, and then changing images for them when the user scrolls to show the move)

Thank.

+3
source share
3 answers

Since I already used ViewPager for swiping UI, I used excellent ViewPagerIndicator . It took about 5 minutes to integrate.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#000000">

    <include android:id="@+id/titlebar_include" layout="@layout/titlebar"/>
    <include layout="@layout/menu"/>

    <android.support.v4.view.ViewPager
        android:layout_width="fill_parent" 
        android:id="@+id/product_viewpager"
        android:layout_height="0dp"
        android:layout_weight="1"
        />

    <com.viewpagerindicator.CirclePageIndicator
        android:id="@+id/indicator"
        android:padding="10dip"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        />
</LinearLayout>
+5
source

, : Gallery ImageViews .

+1

Here is a solution you can try: PageViews and PageIndicator from GreenDroid .

You can also see an example application on the market: https://market.android.com/details?id=com.cyrilmottier.android.gdcatalog

+1
source

Source: https://habr.com/ru/post/1774673/


All Articles