romandanylyk / PageIndicatorView

An page indicator for Android ViewPager
4.63k stars 564 forks source link

PageIndicatorView only work outside viewpager #121

Open mm580486 opened 5 years ago

mm580486 commented 5 years ago

hi i have some problem with com.rd.PageIndicatorView tag i used this tag inside viewpager but i cant see result (dont show in build or design mode) but when i move PageIndicatorView to outside of viewpager works fine

dont show


<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        xmlns:attrs="http://schemas.android.com/apk/res-auto"

        tools:context=".HomeActivity">

    <com.google.android.material.appbar.AppBarLayout
            android:id="@+id/appBarLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#03FFFFFF"
            android:theme="@style/AppTheme.AppBarOverlay">

        <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

            <androidx.viewpager.widget.ViewPager
                    android:id="@+id/viewpager"
                    android:layout_width="match_parent"
                    android:layout_height="200dp"
                    android:clickable="true"
                    android:visibility="visible"
                    tools:visibility="visible"
                    android:focusable="true">

                <com.rd.PageIndicatorView
                        android:id="@+id/pageIndicatorView"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerInParent="true"
                        android:visibility="visible"
                        app:piv_animationType="scale"
                        app:piv_dynamicCount="true"
                        app:piv_interactiveAnimation="true"
                        app:piv_selectedColor="@color/colorPrimary"
                        app:piv_unselectedColor="@color/colorPrimary"
                        app:piv_viewPager="@+id/viewpager"
                        attrs:piv_padding="12dp"
                        attrs:piv_radius="8dp"
                        tools:visibility="visible" />

            </androidx.viewpager.widget.ViewPager>

            <androidx.appcompat.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    android:layout_gravity="top"
                    android:background="@android:color/transparent"
                    app:popupTheme="@style/AppTheme.PopupOverlay" />

        </FrameLayout>
    </com.google.android.material.appbar.AppBarLayout>

    <include
            android:id="@+id/include"
            layout="@layout/content_home"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    <include
            layout="@layout/btm_nav"
            app:layout_anchor="@+id/include"
            app:layout_anchorGravity="center" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>

show

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        xmlns:attrs="http://schemas.android.com/apk/res-auto"

        tools:context=".HomeActivity">

    <com.google.android.material.appbar.AppBarLayout
            android:id="@+id/appBarLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#03FFFFFF"
            android:theme="@style/AppTheme.AppBarOverlay">

        <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

            <androidx.viewpager.widget.ViewPager
                    android:id="@+id/viewpager"
                    android:layout_width="match_parent"
                    android:layout_height="200dp"
                    android:clickable="true"
                    android:visibility="visible"
                    tools:visibility="visible"
                    android:focusable="true">

            </androidx.viewpager.widget.ViewPager>

            <androidx.appcompat.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    android:layout_gravity="top"
                    android:background="@android:color/transparent"
                    app:popupTheme="@style/AppTheme.PopupOverlay" />

        </FrameLayout>

        <com.rd.PageIndicatorView
                android:id="@+id/pageIndicatorView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:visibility="visible"
                app:piv_animationType="scale"
                app:piv_dynamicCount="true"
                app:piv_interactiveAnimation="true"
                app:piv_selectedColor="@color/colorPrimary"
                app:piv_unselectedColor="@color/colorPrimary"
                app:piv_viewPager="@+id/viewpager"
                attrs:piv_padding="12dp"
                attrs:piv_radius="8dp"
                tools:visibility="visible" />
    </com.google.android.material.appbar.AppBarLayout>

    <include
            android:id="@+id/include"
            layout="@layout/content_home"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    <include
            layout="@layout/btm_nav"
            app:layout_anchor="@+id/include"
            app:layout_anchorGravity="center" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>
romandanylyk commented 5 years ago

Hi, it is not supposed to work inside viewpager. If you want to use pageindicatorview with viewpager simply place them in layaut as you want and specify your viewpager id to pageindicatorview via attribute or programmatically.

Hopefully it helps.

On Sun, Sep 1, 2019, 09:06 mohammad mahmoodi notifications@github.com wrote:

hi i have some problem with com.rd.PageIndicatorView tag i used this tag inside viewpager but i cant see result (dont show in build or design mode) but when i move PageIndicatorView to outside of viewpager works fine

dont show

<?xml version="1.0" encoding="utf-8"?> <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:attrs="http://schemas.android.com/apk/res-auto"

    tools:context=".HomeActivity">

<com.google.android.material.appbar.AppBarLayout
        android:id="@+id/appBarLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#03FFFFFF"
        android:theme="@style/AppTheme.AppBarOverlay">

    <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

        <androidx.viewpager.widget.ViewPager
                android:id="@+id/viewpager"
                android:layout_width="match_parent"
                android:layout_height="200dp"
                android:clickable="true"
                android:visibility="visible"
                tools:visibility="visible"
                android:focusable="true">

            <com.rd.PageIndicatorView
                    android:id="@+id/pageIndicatorView"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:visibility="visible"
                    app:piv_animationType="scale"
                    app:piv_dynamicCount="true"
                    app:piv_interactiveAnimation="true"
                    app:piv_selectedColor="@color/colorPrimary"
                    app:piv_unselectedColor="@color/colorPrimary"
                    app:piv_viewPager="@+id/viewpager"
                    attrs:piv_padding="12dp"
                    attrs:piv_radius="8dp"
                    tools:visibility="visible" />

        </androidx.viewpager.widget.ViewPager>

        <androidx.appcompat.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:layout_gravity="top"
                android:background="@android:color/transparent"
                app:popupTheme="@style/AppTheme.PopupOverlay" />

    </FrameLayout>
</com.google.android.material.appbar.AppBarLayout>

<include
        android:id="@+id/include"
        layout="@layout/content_home"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

<include
        layout="@layout/btm_nav"
        app:layout_anchor="@+id/include"
        app:layout_anchorGravity="center" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>

show

<?xml version="1.0" encoding="utf-8"?> <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:attrs="http://schemas.android.com/apk/res-auto"

    tools:context=".HomeActivity">

<com.google.android.material.appbar.AppBarLayout
        android:id="@+id/appBarLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#03FFFFFF"
        android:theme="@style/AppTheme.AppBarOverlay">

    <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

        <androidx.viewpager.widget.ViewPager
                android:id="@+id/viewpager"
                android:layout_width="match_parent"
                android:layout_height="200dp"
                android:clickable="true"
                android:visibility="visible"
                tools:visibility="visible"
                android:focusable="true">

        </androidx.viewpager.widget.ViewPager>

        <androidx.appcompat.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:layout_gravity="top"
                android:background="@android:color/transparent"
                app:popupTheme="@style/AppTheme.PopupOverlay" />

    </FrameLayout>

    <com.rd.PageIndicatorView
            android:id="@+id/pageIndicatorView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:visibility="visible"
            app:piv_animationType="scale"
            app:piv_dynamicCount="true"
            app:piv_interactiveAnimation="true"
            app:piv_selectedColor="@color/colorPrimary"
            app:piv_unselectedColor="@color/colorPrimary"
            app:piv_viewPager="@+id/viewpager"
            attrs:piv_padding="12dp"
            attrs:piv_radius="8dp"
            tools:visibility="visible" />
</com.google.android.material.appbar.AppBarLayout>

<include
        android:id="@+id/include"
        layout="@layout/content_home"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

<include
        layout="@layout/btm_nav"
        app:layout_anchor="@+id/include"
        app:layout_anchorGravity="center" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/romandanylyk/PageIndicatorView/issues/121?email_source=notifications&email_token=ABYQPEBO62PVQPFKLRDUZM3QHNLWDA5CNFSM4ISVYM2KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HIT6JLA, or mute the thread https://github.com/notifications/unsubscribe-auth/ABYQPEFBY4QLKC4DA6RXDW3QHNLWDANCNFSM4ISVYM2A .

mm580486 commented 5 years ago

sorry , can you sho me an example , i cant find layout attr in PageIndicatorView tag

romandanylyk commented 5 years ago

app:piv_viewPager="@id/viewPager"

mm580486 commented 5 years ago

i do it please watch my code in first comment