0
I was able to do it this way:
I used a ViewPager
contentious a SpringDotsIndicator
. I created separate layout files for the CardView
, and inflated them into a Fragment
.
Add this implementation to Gradle:
implementation 'com.tbuonomo.andrui:viewpagerdotsindicator:2.1.2'
Add this snippet to activity_main
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">
<com.tbuonomo.viewpagerdotsindicator.SpringDotsIndicator
android:id="@+id/dots_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:dotsColor="@color/white"
app:dotsCornerRadius="8dp"
app:dotsSize="10dp"
app:dotsSpacing="4dp"
app:dotsWidthFactor="2.5" />
</RelativeLayout>
Note: I added everything inside a LinearLayout
.
In his MainActivity.java
don’t forget to add:
viewPager = findViewById(R.id.view_pager);
dotsIndicator = findViewById(R.id.dots_indicator);
viewPager.setAdapter(adapter);
dotsIndicator.setViewPager(viewPager);