Creating cards in Android Application

Cards Views are one of the best layout for modern applications. In this application we are going to create a simple layout consist of a card. Now you can use this card layout as child view for recycler view or list view.

Step 1: Add the Dependencies

Add the following in app.gradle file

implementation 'com.android.support:cardview-v7:27.1.0'

Step 2: Create A card

<android.support.v7.widget.CardView
        xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:id="@+id/card_view"
        android:layout_gravity="center"
        android:layout_width="match_parent"
        android:layout_marginRight="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="8dp"
        android:layout_height="200dp"
        card_view:cardCornerRadius="4dp">
        <LinearLayout
            android:layout_height="match_parent"
            android:layout_width="match_parent"
            android:orientation="vertical">

            <ImageView
                android:layout_height="150dp"
                android:adjustViewBounds="true"
                android:layout_width="match_parent"
                android:src="@drawable/apc"


                />

            <TextView
                android:id="@+id/info_text"
                android:padding="8dp"
                android:layout_width="match_parent"
                android:text="Hello There this is a Card"
                android:layout_height="match_parent" />

        </LinearLayout>

 

 

About kaushal97

Android Enthusiast

Leave a Reply

Your email address will not be published. Required fields are marked *