The last Article introduced you to Material Design basics. In this Article you will learn how to create a Card View.
Steps to add a CardView
- Add support libraries – com.android.support.cardview and recyclerview
- Create a layout xml file for the card view.
- Refer to the below code snippet
<?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/apk/res-auto" android:id="@+id/card_view" android:layout_width="match_parent" android:layout_height="200dp" android:layout_margin="5dp" card_view:cardCornerRadius="4dp"> <LinearLayout android:layout_width="match_parent" android:layout_height="fill_parent" android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Hello Card View" android:layout_margin="5dp"/> </LinearLayout> </android.support.v7.widget.CardView>
Source Code is available here