Skip to content

hanbikan/custom-indicator-with-viewpager2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

custom-indicator-with-viewpager2

A simple example of custom indicator for ViewPager2. Also it can be attached to recycler view using PagerSnapHelper.

|

|

In XML layout

<com.hanbitkang.custom_indicator_with_viewpager2.CustomIndicator
            android:id="@+id/custom_indicator"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:customIndicatorSize="10dp"
            app:indicatorRadius="5dp"
            app:selectedIndicatorWidthScale="5"
            app:indicatorWidthScale="2"
            app:indicatorMargin="7dp"
            app:indicatorColor="@color/light_gray"
            app:selectedIndicatorColor="@color/light_blue"/>

Arrtibutes

Attributes Description
customIndicatorSize Base size of the indicators
indicatorRadius Corner radius of the indicators
selectedIndicatorWidthScale Determines how large the selected indicator will be(scale by customIndicatorSize)
indicatorWidthScale Determines how large the indicators will be(scale by customIndicatorSize)
indicatorMargin Margin between the indicators
selectedIndicatorColor Color of the selected indicator
indicatorColor Color of the indicators

In Kotlin

customIndicator.setupViewPager2(viewPager2, viewPager2.currentItem)
customindicator.setupRecyclerView(recyclerView, pagerSnapHelper, itemCount, position)

License

Copyright 2022 hanbikan(Hanbit Kang)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

A customized indicator view for ViewPager2

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages