Using cardview in your app for list - puru world official

Using cardview in your app for list

Mar 21, 2018 • 6 min read • ... views
Advertisement




USING CARDVIEW IN YOUR ANDROID APP



Code:





<?xml version="1.0" encoding="utf-8"?>



<ScrollView android:layout_width="match_parent"

    android:layout_height="match_parent"

    xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:app="http://schemas.android.com/apk/res-auto">





    <LinearLayout

        android:layout_width="match_parent"

        android:layout_height="match_parent"

        android:background="#D0FF09"

        android:orientation="vertical">





        <android.support.v7.widget.CardView android:layout_width="match_parent"

            android:layout_height="200dp"

            android:layout_marginTop="10dp"

            android:layout_margin="5dp"

            app:cardCornerRadius="25dp"

            >





            <LinearLayout

                android:layout_width="match_parent"

                android:orientation="vertical"

                android:weightSum="2"

                android:layout_height="fill_parent">



                <ImageView

                    android:layout_width="match_parent"

                    android:layout_height="match_parent"

                    android:layout_weight="0.30"

                    android:src="@drawable/back1"

                    android:scaleType="fitXY"

                    />

                <TextView

                    android:layout_width="match_parent"

                    android:layout_height="match_parent"

                    android:layout_weight="1.70"

                    android:text="THIS IS A LAUNCHER ICON"

                    android:textSize="25dp"

                    android:gravity="center"

                    />





            </LinearLayout>



        </android.support.v7.widget.CardView>













        <android.support.v7.widget.CardView android:layout_width="match_parent"

            android:layout_height="200dp"



            android:layout_marginTop="10dp"

            android:layout_margin="5dp"

            app:cardCornerRadius="25dp"

            >





            <LinearLayout

                android:layout_width="match_parent"

                android:orientation="vertical"

                android:weightSum="2"

                android:layout_height="fill_parent">



                <ImageView

                    android:layout_width="match_parent"

                    android:layout_height="match_parent"

                    android:layout_weight="0.30"

                    android:src="@drawable/back1"

                    android:scaleType="fitXY"

                    />

                <TextView

                    android:layout_width="match_parent"

                    android:layout_height="match_parent"

                    android:layout_weight="1.70"

                    android:text="THIS IS A LAUNCHER ICON"

                    android:textSize="25dp"

                    android:gravity="center"

                    />





            </LinearLayout>



        </android.support.v7.widget.CardView>



        <android.support.v7.widget.CardView android:layout_width="match_parent"

            android:layout_height="200dp"



            android:layout_marginTop="10dp"

            android:layout_margin="5dp"

            app:cardCornerRadius="25dp"

            >





            <LinearLayout

                android:layout_width="match_parent"

                android:orientation="vertical"

                android:weightSum="2"

                android:layout_height="fill_parent">



                <ImageView

                    android:layout_width="match_parent"

                    android:layout_height="match_parent"

                    android:layout_weight="0.30"

                    android:src="@drawable/back1"

                    android:scaleType="fitXY"

                    />

                <TextView

                    android:layout_width="match_parent"

                    android:layout_height="match_parent"

                    android:layout_weight="1.70"

                    android:text="THIS IS A LAUNCHER ICON"

                    android:textSize="25dp"

                    android:gravity="center"

                    />





            </LinearLayout>



        </android.support.v7.widget.CardView>



        <android.support.v7.widget.CardView android:layout_width="match_parent"

            android:layout_height="200dp"



            android:layout_marginTop="10dp"

            android:layout_margin="5dp"

            app:cardCornerRadius="25dp"

            >





            <LinearLayout

                android:layout_width="match_parent"

                android:orientation="vertical"

                android:weightSum="2"

                android:layout_height="fill_parent">



                <ImageView

                    android:layout_width="match_parent"

                    android:layout_height="match_parent"

                    android:layout_weight="0.30"

                    android:src="@drawable/back1"

                    android:scaleType="fitXY"

                    />

                <TextView

                    android:layout_width="match_parent"

                    android:layout_height="match_parent"

                    android:layout_weight="1.70"

                    android:text="THIS IS A LAUNCHER ICON"

                    android:textSize="25dp"

                    android:gravity="center"

                    />





            </LinearLayout>



        </android.support.v7.widget.CardView>





    </LinearLayout>







</ScrollView>



Keywords:

cardview android material design
cardview android github
recyclerview and cardview android example
cardview with image and text in android
cardview android dependency
android cardview with image and text example
cardview material design
recyclerview android tutorial
Advertisement
P

Written by Puru

I am a software builder, developer, and technical writer. I design web products like JSON2Apex and the Python Visualizer. I write these guides to share actual, real-world development solutions and lifestyle strategies. No corporate fluff, just practical code and direct insights.

Need help? Ask our AI guide! 👋