Open fauziasf opened 4 years ago
some code to get you started...
In your own constraintlayout, also add the indicator:
<com.synnapps.carouselview.CarouselView
android:id="@+id/image_carousel"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.synnapps.carouselview.CirclePageIndicator
android:id="@+id/_image_carousel_indicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/image_carousel" />`
then connect the two manually and disable the default indicator:
productsImageCarousel.setIndicatorVisibility(View.GONE) // we have our own indicator
productsImageCarouselIndicator.apply {
setViewPager(imageCarousel.containerViewPager)
isVisible = images.size > 1
fillColor = resources.getColor(R.color.carouselIndicatorSelected, theme)
... etc.
}
some code to get you started...
In your own constraintlayout, also add the indicator:
<com.synnapps.carouselview.CarouselView android:id="@+id/image_carousel" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <com.synnapps.carouselview.CirclePageIndicator android:id="@+id/_image_carousel_indicator" android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/image_carousel" />`
then connect the two manually and disable the default indicator:
productsImageCarousel.setIndicatorVisibility(View.GONE) // we have our own indicator productsImageCarouselIndicator.apply { setViewPager(imageCarousel.containerViewPager) isVisible = images.size > 1 fillColor = resources.getColor(R.color.carouselIndicatorSelected, theme) ... etc. }
I am trying to implement a carousel with dots under the image.
Tried to use your lines but getting this error: "error: containerViewPager has private access in CarouselView".
Please help!
It has a public getter, do you use kotlin? In com.synnapps.carouselview.CarouselView:
public CarouselViewPager getContainerViewPager() {
return containerViewPager;
}
can you help me put the indicator dots below the image slider?