How to create a cardview with "slide" (similar to that of Nubank)? [closed]
Want to improve this question? Add details and make it clearer what problem is being solved by editing this post .
Closed 2 years ago .
improve this questionI am trying to make a layout similar to the cardview
of the main screen of nubank, however, I am not being able to find reference to base myself on. We that I'm having trouble finding, it's like leaving cardview
with these "little dots". Can someone point me to some material, or still give me tips on how to do ?
1 answers
I managed to do as follows:
I used a ViewPager
content a SpringDotsIndicator
. I created separate layout files for the CardView
, and inflated them into a Fragment
.
Add this implementation in 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);