CardView in Android
Hello World, Today we are going to see what is cardview in android and
what it's advantages.
CardView is a widget provided by the android to build a new look and
efficient UI. You can make your app look more professional see examples below.
Cardview is an amazing concept which makes your user experience better than
old android UI. Cardview was released with Android version 5.0 which is
android lollipop.
According to
Android's Official Site, what is
cardview:
CardView API as an easy way for you to show information inside cards that
have a consistent look across the platform. These cards have a default
elevation above their containing view group, so the system draws shadows
below them. Cards provide an easy way to contain a group of views while
providing a consistent style for the container.
What are the advantages of CardView?
Before the cardview, if we want to make something look like a card we mostly
use framelayout but the problem with framelayout was that we need to write a
lot of code to make simple changes but this was solved when cardview released
and it has some more advantages as follows.
- Cardview has elevation property for controlling shadow
- Set the border or corner radius of the card
- Changing background color is easy
- Ripple effect on cardview looks super cool
These are some of the advantages but not the least.
See also:
Load Image from URL in Android
How to add cardview in Android Project
To use cardview in your android project, first, we need to add cardview
dependency in the gradle file.
add below line to add cardview dependency:
After pasting the above code hit the sync button at the top right of the
screen corner, this will download the dependency on the project and you can
use cardview.
After successfully syncing, open your layout XML file and you can now use
cardview like below.
Below are some cardview android examples:
And this is the end of this tutorial.
If you like this article don't forget to subscribe to our newsletter.
Enter your email id for subscribe.
Subscribe to our Newsletter
By subscribing to our newsletter you're agreeing with our T&C.
Share this Article 👇