{"id":4491,"date":"2020-10-25T10:24:55","date_gmt":"2020-10-25T10:24:55","guid":{"rendered":"https:\/\/infyblog.zluck.in\/?p=4491"},"modified":"2025-07-17T09:02:31","modified_gmt":"2025-07-17T09:02:31","slug":"how-to-create-custom-cardview-in-android","status":"publish","type":"post","link":"https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/","title":{"rendered":"How to Create Custom CardView in Android"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"4491\" class=\"elementor elementor-4491\" data-elementor-post-type=\"post\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-b2d1609 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"b2d1609\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-5a3bc0e\" data-id=\"5a3bc0e\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\n\t\t<div class=\"elementor-element elementor-element-25bc9f5 elementor-widget elementor-widget-text-editor\" data-id=\"25bc9f5\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>Cardview is a widget provided by Android to create a new look and functional UI. You can build your app with the following examples to make it look more professional. Cardview is a wonderful concept that makes your user experience better than the Android UI. Cardview is an Android Lollipop released with Android 5.0.<\/p><h2>Customized CardView<\/h2><p>First, add a CardView dependency to the application-level build.gradle file.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-03bf5de elementor-widget elementor-widget-code-highlight\" data-id=\"03bf5de\" data-element_type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-javascript \">\n\t\t\t\t<code readonly=\"true\" class=\"language-javascript\">\n\t\t\t\t\t<xmp>dependencies {     \r\nimplementation\r\n\u2018androidx.cardview:cardview:1.0.0\u2019\r\n}<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-789aca9 elementor-widget elementor-widget-text-editor\" data-id=\"789aca9\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>Then create a drawable background for the cards. For that, create a new drawable resource file inside the drawable folder.<br \/><strong>res &gt; drawable &gt; New &gt; Drawable Resource File.<\/strong><\/p><h2>background1.xml<\/h2>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-eb64f03 elementor-widget elementor-widget-code-highlight\" data-id=\"eb64f03\" data-element_type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-javascript \">\n\t\t\t\t<code readonly=\"true\" class=\"language-javascript\">\n\t\t\t\t\t<xmp><?xml version=\"1.0\" encoding=\"utf-8\"?> \r\n<shape xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\">\r\n<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-394cdfa elementor-widget elementor-widget-image\" data-id=\"394cdfa\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" width=\"304\" height=\"154\" src=\"https:\/\/infyom.com\/blog\/wp-content\/uploads\/2024\/07\/2020-12-19-5fde3dee29429.png\" class=\"attachment-large size-large wp-image-4498\" alt=\"background2.xml\" srcset=\"https:\/\/infyom.com\/blog\/wp-content\/uploads\/2024\/07\/2020-12-19-5fde3dee29429.png 304w, https:\/\/infyom.com\/blog\/wp-content\/uploads\/2024\/07\/2020-12-19-5fde3dee29429-300x152.png 300w\" sizes=\"(max-width: 304px) 100vw, 304px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-6733c34 elementor-widget elementor-widget-text-editor\" data-id=\"6733c34\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<h2>background2.xml<\/h2>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-98dfb64 elementor-widget elementor-widget-code-highlight\" data-id=\"98dfb64\" data-element_type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-javascript \">\n\t\t\t\t<code readonly=\"true\" class=\"language-javascript\">\n\t\t\t\t\t<xmp><?xml version=\"1.0\" encoding=\"utf-8\"?> \r\n<shape xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"><\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-3034096 elementor-widget elementor-widget-image\" data-id=\"3034096\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<img fetchpriority=\"high\" decoding=\"async\" width=\"351\" height=\"175\" src=\"https:\/\/infyom.com\/blog\/wp-content\/uploads\/2024\/07\/2020-12-19-5fde3e6ff0c02.png\" class=\"attachment-large size-large wp-image-4502\" alt=\"background3.xml\" srcset=\"https:\/\/infyom.com\/blog\/wp-content\/uploads\/2024\/07\/2020-12-19-5fde3e6ff0c02.png 351w, https:\/\/infyom.com\/blog\/wp-content\/uploads\/2024\/07\/2020-12-19-5fde3e6ff0c02-300x150.png 300w\" sizes=\"(max-width: 351px) 100vw, 351px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-ee135fd elementor-widget elementor-widget-text-editor\" data-id=\"ee135fd\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<h2>background3.xml<\/h2>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-b2a2b20 elementor-widget elementor-widget-code-highlight\" data-id=\"b2a2b20\" data-element_type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-javascript \">\n\t\t\t\t<code readonly=\"true\" class=\"language-javascript\">\n\t\t\t\t\t<xmp>\r\n<?xml version=\"1.0\" encoding=\"utf-8\"?> \r\n<shape xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"><\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-bb4ffc1 elementor-widget elementor-widget-image\" data-id=\"bb4ffc1\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" width=\"351\" height=\"175\" src=\"https:\/\/infyom.com\/blog\/wp-content\/uploads\/2024\/07\/2020-12-19-5fde3e85f161c.png\" class=\"attachment-large size-large wp-image-4504\" alt=\"activity_main.xml\" srcset=\"https:\/\/infyom.com\/blog\/wp-content\/uploads\/2024\/07\/2020-12-19-5fde3e85f161c.png 351w, https:\/\/infyom.com\/blog\/wp-content\/uploads\/2024\/07\/2020-12-19-5fde3e85f161c-300x150.png 300w\" sizes=\"(max-width: 351px) 100vw, 351px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-fcb49f5 elementor-widget elementor-widget-text-editor\" data-id=\"fcb49f5\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>Now create a card view in the main XML file. Here I used LinearLayout as the root widget, after using the card view. Below the codes that give you an idea of how to customize the card.<br \/>You can change it according to your needs.<\/p><h2>activity_main.xml<\/h2>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-7eb77fa elementor-widget elementor-widget-code-highlight\" data-id=\"7eb77fa\" data-element_type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-javascript \">\n\t\t\t\t<code readonly=\"true\" class=\"language-javascript\">\n\t\t\t\t\t<xmp><?xml version=\"1.0\" encoding=\"utf-8\"?> \r\n<LinearLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\" xmlns:app=\"http:\/\/schemas.android.com\/apk\/res-auto\"\r\nxmlns:tools=\"http:\/\/schemas.android.com\/tools\"\r\nandroid:layout_width=\"match_parent\"     \r\nandroid:layout_height=\"match_parent\"     \r\nandroid:orientation=\"vertical\">\r\n    <androidx.cardview.widget.CardView\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"173dp\"\r\n        android:layout_marginStart=\"20dp\"\r\n        android:layout_marginTop=\"20dp\"\r\n        android:layout_marginEnd=\"20dp\"\r\n        app:cardCornerRadius=\"8dp\">\r\n\r\n        <LinearLayout\r\n            android:id=\"@+id\/linearLayout1\"\r\n            android:layout_width=\"match_parent\"\r\n            android:layout_height=\"match_parent\"\r\n            android:background=\"@drawable\/bg1\"\r\n            android:orientation=\"vertical\">\r\n\r\n            <LinearLayout\r\n                android:layout_width=\"match_parent\"\r\n                android:layout_height=\"wrap_content\"\r\n                android:layout_marginStart=\"30dp\"\r\n                android:layout_marginTop=\"20dp\"\r\n                android:layout_marginEnd=\"30dp\"\r\n                android:orientation=\"horizontal\">\r\n\r\n                <LinearLayout\r\n                    android:layout_width=\"wrap_content\"\r\n                    android:layout_height=\"wrap_content\"\r\n                    android:orientation=\"vertical\">\r\n\r\n                    <TextView\r\n                        android:layout_width=\"wrap_content\"\r\n                        android:layout_height=\"wrap_content\"\r\n                        android:text=\"Assam\"\r\n                        android:textColor=\"#000000\"\r\n                        android:textSize=\"22sp\" \/>\r\n\r\n                    <TextView\r\n                        android:layout_width=\"wrap_content\"\r\n                        android:layout_height=\"wrap_content\"\r\n                        android:text=\"Current Location\"\r\n                        android:textColor=\"#000000\"\r\n                        android:textSize=\"14sp\" \/>\r\n                <\/LinearLayout>\r\n\r\n            <\/LinearLayout>\r\n\r\n            <LinearLayout\r\n                android:layout_width=\"match_parent\"\r\n                android:layout_height=\"match_parent\"\r\n                android:layout_marginStart=\"30dp\"\r\n                android:layout_marginTop=\"20dp\"\r\n                android:layout_marginEnd=\"30dp\"\r\n                android:orientation=\"horizontal\">\r\n\r\n                <TextView\r\n                    android:layout_width=\"wrap_content\"\r\n                    android:layout_height=\"wrap_content\"\r\n                    android:text=\"25\"\r\n                    android:textColor=\"#000000\"\r\n                    android:textSize=\"28sp\" \/>\r\n\r\n                <LinearLayout\r\n                    android:layout_width=\"wrap_content\"\r\n                    android:layout_height=\"wrap_content\"\r\n                    android:orientation=\"vertical\">\r\n\r\n                    <TextView\r\n                        android:layout_width=\"wrap_content\"\r\n                        android:layout_height=\"wrap_content\"\r\n                        android:layout_marginStart=\"6dp\"\r\n                        android:text=\"o\"\r\n                        android:textColor=\"#000000\"\r\n                        android:textSize=\"13sp\" \/>\r\n\r\n                <\/LinearLayout>\r\n\r\n                <TextView\r\n                    android:layout_width=\"wrap_content\"\r\n                    android:layout_height=\"wrap_content\"\r\n                    android:text=\"18 %\"\r\n                    android:textColor=\"#000000\"\r\n                    android:textSize=\"14sp\" \/>\r\n\r\n                <RelativeLayout\r\n                    android:layout_width=\"match_parent\"\r\n                    android:layout_height=\"match_parent\">\r\n\r\n                    <TextView\r\n                        android:layout_width=\"wrap_content\"\r\n                        android:layout_height=\"wrap_content\"\r\n                        android:layout_alignParentEnd=\"true\"\r\n                        android:layout_marginStart=\"6dp\"\r\n                        android:text=\"11.25 AM\"\r\n                        android:textColor=\"#000000\"\r\n                        android:textSize=\"14sp\" \/>\r\n                <\/RelativeLayout>\r\n            <\/LinearLayout>\r\n        <\/LinearLayout>\r\n    <\/androidx.cardview.widget.CardView>\r\n\r\n    <androidx.cardview.widget.CardView\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"173dp\"\r\n        android:layout_marginStart=\"20dp\"\r\n        android:layout_marginTop=\"20dp\"\r\n        android:layout_marginEnd=\"20dp\"\r\n        app:cardCornerRadius=\"8dp\">\r\n\r\n        <LinearLayout\r\n            android:layout_width=\"match_parent\"\r\n            android:layout_height=\"match_parent\"\r\n            android:background=\"@drawable\/bg2\"\r\n            android:orientation=\"vertical\">\r\n\r\n            <LinearLayout\r\n                android:layout_width=\"match_parent\"\r\n                android:layout_height=\"wrap_content\"\r\n                android:layout_marginStart=\"30dp\"\r\n                android:layout_marginTop=\"20dp\"\r\n                android:layout_marginEnd=\"30dp\"\r\n                android:orientation=\"horizontal\">\r\n\r\n                <LinearLayout\r\n                    android:layout_width=\"wrap_content\"\r\n                    android:layout_height=\"wrap_content\"\r\n                    android:orientation=\"vertical\">\r\n\r\n                    <TextView\r\n                        android:layout_width=\"wrap_content\"\r\n                        android:layout_height=\"wrap_content\"\r\n                        android:text=\"Delhi\"\r\n                        android:textColor=\"@color\/white\"\r\n                        android:textSize=\"22sp\" \/>\r\n\r\n                    <TextView\r\n                        android:layout_width=\"wrap_content\"\r\n                        android:layout_height=\"wrap_content\"\r\n                        android:text=\"2 days ago\"\r\n                        android:textColor=\"@color\/white\"\r\n                        android:textSize=\"14sp\" \/>\r\n                <\/LinearLayout>\r\n\r\n            <\/LinearLayout>\r\n\r\n            <LinearLayout\r\n                android:layout_width=\"match_parent\"\r\n                android:layout_height=\"match_parent\"\r\n                android:layout_marginStart=\"30dp\"\r\n                android:layout_marginTop=\"20dp\"\r\n                android:layout_marginEnd=\"30dp\"\r\n                android:orientation=\"horizontal\">\r\n\r\n                <TextView\r\n                    android:layout_width=\"wrap_content\"\r\n                    android:layout_height=\"wrap_content\"\r\n                    android:text=\"39\"\r\n                    android:textColor=\"@color\/white\"\r\n                    android:textSize=\"28sp\" \/>\r\n\r\n                <LinearLayout\r\n                    android:layout_width=\"wrap_content\"\r\n                    android:layout_height=\"wrap_content\"\r\n                    android:orientation=\"vertical\">\r\n\r\n                    <TextView\r\n                        android:layout_width=\"wrap_content\"\r\n                        android:layout_height=\"wrap_content\"\r\n                        android:layout_marginStart=\"6dp\"\r\n                        android:text=\"o\"\r\n                        android:textColor=\"@color\/white\"\r\n                        android:textSize=\"13sp\" \/>\r\n\r\n                <\/LinearLayout>\r\n\r\n                <TextView\r\n                    android:layout_width=\"wrap_content\"\r\n                    android:layout_height=\"wrap_content\"\r\n                    android:text=\"35 %\"\r\n                    android:textColor=\"@color\/white\"\r\n                    android:textSize=\"14sp\" \/>\r\n\r\n                <RelativeLayout\r\n                    android:layout_width=\"match_parent\"\r\n                    android:layout_height=\"match_parent\">\r\n\r\n                    <TextView\r\n                        android:layout_width=\"wrap_content\"\r\n                        android:layout_height=\"wrap_content\"\r\n                        android:layout_alignParentEnd=\"true\"\r\n                        android:layout_marginStart=\"6dp\"\r\n                        android:text=\"01.05 PM\"\r\n                        android:textColor=\"#D6D6D6\"\r\n                        android:textSize=\"14sp\" \/>\r\n                <\/RelativeLayout>\r\n            <\/LinearLayout>\r\n        <\/LinearLayout>\r\n    <\/androidx.cardview.widget.CardView>\r\n\r\n    <androidx.cardview.widget.CardView\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"173dp\"\r\n        android:layout_marginStart=\"20dp\"\r\n        android:layout_marginTop=\"20dp\"\r\n        android:layout_marginEnd=\"20dp\"\r\n        app:cardCornerRadius=\"8dp\">\r\n\r\n        <LinearLayout\r\n            android:layout_width=\"match_parent\"\r\n            android:layout_height=\"match_parent\"\r\n            android:background=\"@drawable\/bg3\"\r\n            android:orientation=\"vertical\">\r\n\r\n            <LinearLayout\r\n                android:layout_width=\"match_parent\"\r\n                android:layout_height=\"wrap_content\"\r\n                android:layout_marginStart=\"30dp\"\r\n                android:layout_marginTop=\"20dp\"\r\n                android:layout_marginEnd=\"30dp\"\r\n                android:orientation=\"horizontal\">\r\n\r\n                <LinearLayout\r\n                    android:layout_width=\"wrap_content\"\r\n                    android:layout_height=\"wrap_content\"\r\n                    android:orientation=\"vertical\">\r\n\r\n                    <TextView\r\n                        android:layout_width=\"wrap_content\"\r\n                        android:layout_height=\"wrap_content\"\r\n                        android:text=\"Darjeeling\"\r\n                        android:textColor=\"#000000\"\r\n                        android:textSize=\"22sp\" \/>\r\n\r\n                    <TextView\r\n                        android:layout_width=\"wrap_content\"\r\n                        android:layout_height=\"wrap_content\"\r\n                        android:text=\"2 weeks ago\"\r\n                        android:textColor=\"#000000\"\r\n                        android:textSize=\"14sp\" \/>\r\n                <\/LinearLayout>\r\n\r\n            <\/LinearLayout>\r\n\r\n            <LinearLayout\r\n                android:layout_width=\"match_parent\"\r\n                android:layout_height=\"match_parent\"\r\n                android:layout_marginStart=\"30dp\"\r\n                android:layout_marginTop=\"20dp\"\r\n                android:layout_marginEnd=\"30dp\"\r\n                android:orientation=\"horizontal\">\r\n\r\n                <TextView\r\n                    android:layout_width=\"wrap_content\"\r\n                    android:layout_height=\"wrap_content\"\r\n                    android:text=\"12\"\r\n                    android:textColor=\"#000000\"\r\n                    android:textSize=\"28sp\" \/>\r\n\r\n                <LinearLayout\r\n                    android:layout_width=\"wrap_content\"\r\n                    android:layout_height=\"wrap_content\"\r\n                    android:orientation=\"vertical\">\r\n\r\n                    <TextView\r\n                        android:layout_width=\"wrap_content\"\r\n                        android:layout_height=\"wrap_content\"\r\n                        android:layout_marginStart=\"6dp\"\r\n                        android:text=\"o\"\r\n                        android:textColor=\"#000000\"\r\n                        android:textSize=\"13sp\" \/>\r\n\r\n                <\/LinearLayout>\r\n\r\n                <TextView\r\n                    android:layout_width=\"wrap_content\"\r\n                    android:layout_height=\"wrap_content\"\r\n                    android:text=\"9 %\"\r\n                    android:textColor=\"#000000\"\r\n                    android:textSize=\"14sp\" \/>\r\n\r\n                <RelativeLayout\r\n                    android:layout_width=\"match_parent\"\r\n                    android:layout_height=\"match_parent\">\r\n\r\n                    <TextView\r\n                        android:layout_width=\"wrap_content\"\r\n                        android:layout_height=\"wrap_content\"\r\n                        android:layout_alignParentEnd=\"true\"\r\n                        android:layout_marginStart=\"6dp\"\r\n                        android:text=\"05.00 AM\"\r\n                        android:textColor=\"#000000\"\r\n                        android:textSize=\"14sp\" \/>\r\n                <\/RelativeLayout>\r\n            <\/LinearLayout>\r\n        <\/LinearLayout>\r\n    <\/androidx.cardview.widget.CardView>\r\n<\/LinearLayout><\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-4b1c748 elementor-widget elementor-widget-text-editor\" data-id=\"4b1c748\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<h2>Output :-<\/h2>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-fa1d461 elementor-widget elementor-widget-image\" data-id=\"fa1d461\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"351\" height=\"627\" src=\"https:\/\/infyom.com\/blog\/wp-content\/uploads\/2024\/07\/2020-12-19-5fde3efbe6c31.png\" class=\"attachment-large size-large wp-image-4516\" alt=\"Output\" srcset=\"https:\/\/infyom.com\/blog\/wp-content\/uploads\/2024\/07\/2020-12-19-5fde3efbe6c31.png 351w, https:\/\/infyom.com\/blog\/wp-content\/uploads\/2024\/07\/2020-12-19-5fde3efbe6c31-168x300.png 168w\" sizes=\"(max-width: 351px) 100vw, 351px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t\n    <div class=\"xs_social_share_widget xs_share_url after_content \t\tmain_content  wslu-style-1 wslu-share-box-shaped wslu-fill-colored wslu-none wslu-share-horizontal wslu-theme-font-no wslu-main_content\">\n\n\t\t\n        <ul>\n\t\t\t        <\/ul>\n    <\/div> \n","protected":false},"excerpt":{"rendered":"<p>Cardview is a widget provided by Android to create a new look and functional UI. You can build your app with the&#8230;<\/p>\n","protected":false},"author":2,"featured_media":4494,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"postBodyCss":"","postBodyMargin":[],"postBodyPadding":[],"postBodyBackground":{"backgroundType":"classic","gradient":""},"two_page_speed":[],"footnotes":""},"categories":[11],"tags":[142,19],"class_list":["post-4491","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-android-development","tag-cardview","tag-learning"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Create Custom CardView in Android<\/title>\n<meta name=\"description\" content=\"Create custom CardViews in Android, design custom layouts, apply styles, elevation, shape, and integrate they into RecyclerViews or UIs.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Create Custom CardView in Android\" \/>\n<meta property=\"og:description\" content=\"Create custom CardViews in Android, design custom layouts, apply styles, elevation, shape, and integrate they into RecyclerViews or UIs.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog | InfyOm Technologies\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/infyom\" \/>\n<meta property=\"article:published_time\" content=\"2020-10-25T10:24:55+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-07-17T09:02:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/infyom.com\/blog\/wp-content\/uploads\/2024\/07\/2020-12-19-5fde409f2b133-1-1-1-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"772\" \/>\n\t<meta property=\"og:image:height\" content=\"484\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"InfyOm\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@InfyOm\" \/>\n<meta name=\"twitter:site\" content=\"@InfyOm\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"InfyOm\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/\"},\"author\":{\"name\":\"InfyOm\",\"@id\":\"https:\/\/infyom.com\/blog\/#\/schema\/person\/659bfc844c333d041221e83c5f5ec754\"},\"headline\":\"How to Create Custom CardView in Android\",\"datePublished\":\"2020-10-25T10:24:55+00:00\",\"dateModified\":\"2025-07-17T09:02:31+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/\"},\"wordCount\":157,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/infyom.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/infyom.com\/blog\/wp-content\/uploads\/2024\/07\/2020-12-19-5fde409f2b133-1-1-1-1.png\",\"keywords\":[\"CardView\",\"Learning\"],\"articleSection\":[\"Android Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/\",\"url\":\"https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/\",\"name\":\"How to Create Custom CardView in Android\",\"isPartOf\":{\"@id\":\"https:\/\/infyom.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/infyom.com\/blog\/wp-content\/uploads\/2024\/07\/2020-12-19-5fde409f2b133-1-1-1-1.png\",\"datePublished\":\"2020-10-25T10:24:55+00:00\",\"dateModified\":\"2025-07-17T09:02:31+00:00\",\"description\":\"Create custom CardViews in Android, design custom layouts, apply styles, elevation, shape, and integrate they into RecyclerViews or UIs.\",\"breadcrumb\":{\"@id\":\"https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/#primaryimage\",\"url\":\"https:\/\/infyom.com\/blog\/wp-content\/uploads\/2024\/07\/2020-12-19-5fde409f2b133-1-1-1-1.png\",\"contentUrl\":\"https:\/\/infyom.com\/blog\/wp-content\/uploads\/2024\/07\/2020-12-19-5fde409f2b133-1-1-1-1.png\",\"width\":772,\"height\":484,\"caption\":\"How to Create Custom CardView in Android\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/infyom.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Create Custom CardView in Android\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/infyom.com\/blog\/#website\",\"url\":\"https:\/\/infyom.com\/blog\/\",\"name\":\"Blog | InfyOm Technologies\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/infyom.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/infyom.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/infyom.com\/blog\/#organization\",\"name\":\"InfyOm Technologies\",\"url\":\"https:\/\/infyom.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/infyom.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/infyom.com\/blog\/wp-content\/uploads\/2024\/06\/InfyOm-Logo.png\",\"contentUrl\":\"https:\/\/infyom.com\/blog\/wp-content\/uploads\/2024\/06\/InfyOm-Logo.png\",\"width\":88,\"height\":41,\"caption\":\"InfyOm Technologies\"},\"image\":{\"@id\":\"https:\/\/infyom.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/infyom\",\"https:\/\/x.com\/InfyOm\",\"https:\/\/www.instagram.com\/infyomtechnologies\/\",\"https:\/\/in.linkedin.com\/company\/infyom-technologies\",\"https:\/\/github.com\/infyomlabs\",\"https:\/\/x.com\/infyom\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/infyom.com\/blog\/#\/schema\/person\/659bfc844c333d041221e83c5f5ec754\",\"name\":\"InfyOm\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/infyom.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/1ad162864d8d33c04ea9e6d0333cc483?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/1ad162864d8d33c04ea9e6d0333cc483?s=96&d=mm&r=g\",\"caption\":\"InfyOm\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Create Custom CardView in Android","description":"Create custom CardViews in Android, design custom layouts, apply styles, elevation, shape, and integrate they into RecyclerViews or UIs.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/","og_locale":"en_US","og_type":"article","og_title":"How to Create Custom CardView in Android","og_description":"Create custom CardViews in Android, design custom layouts, apply styles, elevation, shape, and integrate they into RecyclerViews or UIs.","og_url":"https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/","og_site_name":"Blog | InfyOm Technologies","article_publisher":"https:\/\/www.facebook.com\/infyom","article_published_time":"2020-10-25T10:24:55+00:00","article_modified_time":"2025-07-17T09:02:31+00:00","og_image":[{"width":772,"height":484,"url":"https:\/\/infyom.com\/blog\/wp-content\/uploads\/2024\/07\/2020-12-19-5fde409f2b133-1-1-1-1.png","type":"image\/png"}],"author":"InfyOm","twitter_card":"summary_large_image","twitter_creator":"@InfyOm","twitter_site":"@InfyOm","twitter_misc":{"Written by":"InfyOm","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/#article","isPartOf":{"@id":"https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/"},"author":{"name":"InfyOm","@id":"https:\/\/infyom.com\/blog\/#\/schema\/person\/659bfc844c333d041221e83c5f5ec754"},"headline":"How to Create Custom CardView in Android","datePublished":"2020-10-25T10:24:55+00:00","dateModified":"2025-07-17T09:02:31+00:00","mainEntityOfPage":{"@id":"https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/"},"wordCount":157,"commentCount":0,"publisher":{"@id":"https:\/\/infyom.com\/blog\/#organization"},"image":{"@id":"https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/#primaryimage"},"thumbnailUrl":"https:\/\/infyom.com\/blog\/wp-content\/uploads\/2024\/07\/2020-12-19-5fde409f2b133-1-1-1-1.png","keywords":["CardView","Learning"],"articleSection":["Android Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/","url":"https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/","name":"How to Create Custom CardView in Android","isPartOf":{"@id":"https:\/\/infyom.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/#primaryimage"},"image":{"@id":"https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/#primaryimage"},"thumbnailUrl":"https:\/\/infyom.com\/blog\/wp-content\/uploads\/2024\/07\/2020-12-19-5fde409f2b133-1-1-1-1.png","datePublished":"2020-10-25T10:24:55+00:00","dateModified":"2025-07-17T09:02:31+00:00","description":"Create custom CardViews in Android, design custom layouts, apply styles, elevation, shape, and integrate they into RecyclerViews or UIs.","breadcrumb":{"@id":"https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/#primaryimage","url":"https:\/\/infyom.com\/blog\/wp-content\/uploads\/2024\/07\/2020-12-19-5fde409f2b133-1-1-1-1.png","contentUrl":"https:\/\/infyom.com\/blog\/wp-content\/uploads\/2024\/07\/2020-12-19-5fde409f2b133-1-1-1-1.png","width":772,"height":484,"caption":"How to Create Custom CardView in Android"},{"@type":"BreadcrumbList","@id":"https:\/\/infyom.com\/blog\/how-to-create-custom-cardview-in-android\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/infyom.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Create Custom CardView in Android"}]},{"@type":"WebSite","@id":"https:\/\/infyom.com\/blog\/#website","url":"https:\/\/infyom.com\/blog\/","name":"Blog | InfyOm Technologies","description":"","publisher":{"@id":"https:\/\/infyom.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/infyom.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/infyom.com\/blog\/#organization","name":"InfyOm Technologies","url":"https:\/\/infyom.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/infyom.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/infyom.com\/blog\/wp-content\/uploads\/2024\/06\/InfyOm-Logo.png","contentUrl":"https:\/\/infyom.com\/blog\/wp-content\/uploads\/2024\/06\/InfyOm-Logo.png","width":88,"height":41,"caption":"InfyOm Technologies"},"image":{"@id":"https:\/\/infyom.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/infyom","https:\/\/x.com\/InfyOm","https:\/\/www.instagram.com\/infyomtechnologies\/","https:\/\/in.linkedin.com\/company\/infyom-technologies","https:\/\/github.com\/infyomlabs","https:\/\/x.com\/infyom"]},{"@type":"Person","@id":"https:\/\/infyom.com\/blog\/#\/schema\/person\/659bfc844c333d041221e83c5f5ec754","name":"InfyOm","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/infyom.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/1ad162864d8d33c04ea9e6d0333cc483?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1ad162864d8d33c04ea9e6d0333cc483?s=96&d=mm&r=g","caption":"InfyOm"}}]}},"_links":{"self":[{"href":"https:\/\/infyom.com\/blog\/wp-json\/wp\/v2\/posts\/4491","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/infyom.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/infyom.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/infyom.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/infyom.com\/blog\/wp-json\/wp\/v2\/comments?post=4491"}],"version-history":[{"count":24,"href":"https:\/\/infyom.com\/blog\/wp-json\/wp\/v2\/posts\/4491\/revisions"}],"predecessor-version":[{"id":8182,"href":"https:\/\/infyom.com\/blog\/wp-json\/wp\/v2\/posts\/4491\/revisions\/8182"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/infyom.com\/blog\/wp-json\/wp\/v2\/media\/4494"}],"wp:attachment":[{"href":"https:\/\/infyom.com\/blog\/wp-json\/wp\/v2\/media?parent=4491"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/infyom.com\/blog\/wp-json\/wp\/v2\/categories?post=4491"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/infyom.com\/blog\/wp-json\/wp\/v2\/tags?post=4491"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}