Skip to content

Vp2IndicatorView

Add: Version 0.2.0

Vp2IndicatorView

Quick start

Add: Version 0.2.0

<com.ave.vastgui.tools.view.vp2indicator.Vp2IndicatorView
    android:id="@+id/vp2indicator"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="20dp"
    app:indicator_item_count="3" />
AndroidView(factory = { ctx ->
    Vp2IndicatorView(ctx).apply {
        setIndicatorItemCount(5)
        setIndicatorCircleRadius(20f)
    }
})

Default style

Attach to ViewPager2

Add: Version 0.2.0

Calling attachToViewPager2 to attach to ViewPager2 .

attachToViewPager2

After attachToViewPager2() is called, it will no longer be allowed to set the count of indicators and the current index of indicator.

binding.vp2indicator.attachToViewPager2(binding.vp2)

Radius of indicator

Add: Version 0.2.0

When the style of the indicator is Style.CIRCLE , the radius of indicator can be set by calling setIndicatorCircleRadius .

binding.vp2indicator.setIndicatorCircleRadius(8f.DP)

Default size

Change size

Color of indicator

Add: Version 0.2.0

When the style of the indicator is Style.CIRCLE , the color of the indicator can be set by calling setSelectedColor and setUnSelectedColor .

binding.vp2indicator.apply {
    setSelectedColor(R.color.tomato)
    setUnSelectedColor(R.color.limegreen)
    ... 
}

Circle indicator color

Interval width of indicator

Add: Version 0.2.0

The interval width of indicator can be set by indicator_item_distance or calling setIndicatorItemDistance to change the gap distance.

binding.vp2indicator.setIndicatorItemDistance(10f.DP)
<com.ave.vastgui.tools.view.viewpager2.indicator.Vp2IndicatorView
    ...
    app:indicator_item_distance="10dp" />

Style of indicator

Add: Version 0.5.0   Update: Version 1.5.2

The indicator style can be set by setIndicatorStyle or calling setIndicatorStyle , Vp2IndicatorView currently supports two types:

  • CIRCLE
  • BITMAP
binding.vp2indicator.setIndicatorStyle(Vp2IndicatorView.Style.CIRCLE)
<com.ave.vastgui.tools.view.viewpager2.indicator.Vp2IndicatorView
    ...
    app:indicator_style="circle" />

Bitmap of indicator

Add: Version 0.5.0

binding.vp2indicator.apply {
    setIndicatorStyle(Style.BITMAP)
    setBitmapSize(20f.DP.toInt(),20f.DP.toInt())
    setSelectedBitmap(R.drawable.ic_indicator_select)
    setUnSelectedBitmap(R.drawable.ic_indicator_unselect)
    ... 
}

bitmap

Sample code

Sample code