Cardview with dividers in it

Amer Mograbi picture Amer Mograbi · May 9, 2015 · Viewed 29.4k times · Source

I've seen those CardViews (I'm not sure they're even CardViews) with dividers used in a lot of apps, so I'm guessing there is an easy way to create them. I wanted to ask how is it exactly done? are those even CardViews?

I couldn't find out more about them because I didn't know the name of the View exactly, so If someone could direct me to an example with code I'd be grateful.

Image example: enter image description here

Answer

Vishwajit Palankar picture Vishwajit Palankar · May 9, 2015

You can use this code this may help

 <android.support.v7.widget.CardView
        android:id="@+id/cardview"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/margin_large"
        android:layout_marginRight="@dimen/margin_large"
        android:elevation="100dp"
        card_view:cardBackgroundColor="@android:color/white"
        card_view:cardCornerRadius="8dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:gravity="center_vertical"
                android:paddingLeft="25dp">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Conversations" />
            </LinearLayout>

            <View
                android:layout_width="match_parent"
                android:layout_height="2dp"
                android:background="@android:color/darker_gray" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:paddingLeft="30dp"
                android:paddingTop="20dp"
                android:paddingBottom="10dp">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="game" />
                    ...
            </LinearLayout>
        </LinearLayout>
    </android.support.v7.widget.CardView>