I was able to do the following:
I've used ViewPager
content SpringDotsIndicator
. I created separate layout files for CardView
, and inflated them to 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 your MainActivity.java
do not forget to add:
viewPager = findViewById(R.id.view_pager);
dotsIndicator = findViewById(R.id.dots_indicator);
viewPager.setAdapter(adapter);
dotsIndicator.setViewPager(viewPager);