ViewPager2-Examples
ViewPager2-Examples copied to clipboard
When coming first time in app then dot indicator is not showing
When app get started, view pager is showing but dot indicator is not showing. When we scrolled view pager then dot indicator is showing, but first time having issue. Can you give any solution or advice
I fixed by doing the dot indicator logic inside layoutDots.post {}
layoutDots.post {
layoutDots.removeAllViews()
for (i in dots.indices) {
dots[i] = TextView(this)
dots[i]?.text = Html.fromHtml("•")
dots[i]?.textSize = 35f
dots[i]?.setTextColor(colorsInactive)
layoutDots.addView(dots[i])
}
if (dots.isNotEmpty()) {
dots[currentPage]?.setTextColor(colorsActive)
}
}