https://iteritory.com/android-cardview-tutorial-with-example/
In previous tutorials we learnt horizontal list and vertical list using recyclerview. This Android tutorial is to add cardview in apps with recyclerview. An example app has been developed to demonstrate the concepts of Android Cardview.
In previous tutorials we learnt horizontal list and vertical list using recyclerview. This Android tutorial is to add cardview in apps with recyclerview. An example app has been developed to demonstrate the concepts of Android Cardview.
Cardview is a very powerful UI tool. You may add photo, texts, links etc in a card to give your user one nice representation of the information you want to share. By combining recyclerview and cardview, we can give our apps a beautiful representation. While, I am no UX designer, I will cover the necessary points for you to explore your own creativity. So, without further ado, let’s get started.
App Demo
Before we start with the development, let’s first take a look as to what we are going to create as part of this tutorial.
Tech Stack
We have used following tech stack in this app
Basic tasks for implementing cardview
Following are the basic tasks while implementing cardview –
- Add the dependency for cardview and recyclerview.
- Write a model class for the information you want to display in the cardview. In my case it’s grocery items
- Write a XML layout file to depict information visually on the card view/recycler view.
- Write a custom adapter to inflate the recyclerview.
- Modify the acitivity_main.xml to include recyclerview
- And finally harness these changes from MainActivity.java; populate data
- And that’s it. You just understood the basic skeleton of a cardview project.
Let’s get started!
Create an empty project
- Launch Android Studio and click: File –> New –> New Project…
- A “Create New Project” dialog box will open; we’ll provide the app name and company domain. I have entered following details, you can provide the name/domain as per your choice and preference.
- Application Name:- ItcCardView
- Company Domain:- iteritory.com
- Click on Next button. In the next window, select the minimum SDK version; you can choose as per your preference. In this case, I have chosen API 16: Android 4.1 (Jelly Bean). Click Next button.
- In the next window, select “Empty Activity“. Click Next button.
- In the next window, let’s keep the Activity Name and Layout Name to default. Click Finish button.
- I’ll change the app name a bit here, traverse and open res–> values –> strings.xml. Find the line with app_name attribute. Change the value to “My CardView App”.
Comments
Post a Comment