How to create a cardview with "slide" (similar to Nubank)?

Asked

Viewed 194 times

0

I’m trying to make a layout similar to cardview of the main screen of the nubank, however, I am not able to find reference to base myself. What I’m having trouble finding, is how to leave the cardview with these "dots". Someone can show me some material, or give me tips on how to do ?

inserir a descrição da imagem aqui

1 answer

1


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);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.