I want to use CardView to make the screen more beautiful just that the cardView works similar to a listView?

0

And I want to get dynamic data to show on the screen. Dynamic data coming from a webservice.

So, do I need to use RecyclerView with CardView Layout to make the data dynamic?

How can I make my CardView look like elements of a ListView?

    
asked by anonymous 24.01.2017 / 15:30

1 answer

2

First, after the project is created, go to the file build.gradle (app) and add the following dependencies:

compile ‘com.android.support:cardview-v7:21.0.+’
compile ‘com.android.support:recyclerview-v7:21.0.+’

Then there's an item in your list, which is probably defined in your adapter . The following code example shows how to include a widget widget with layout :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    ... >
    <!-- Um CardView com um TextView dentro -->
    <android.support.v7.widget.CardView
        android:id="@+id/card_view"
        android:layout_gravity="center"
        android:layout_width="200dp"
        android:layout_height="200dp"
        card_view:cardCornerRadius="4dp">

        <TextView
            android:id="@+id/info_text"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </android.support.v7.widget.CardView>
</LinearLayout>

See the how to create lists and cards documentation at .

    
24.01.2017 / 15:36