0

I wanted a cardview with only bottom border. So i found a solution :

toolbar_background.xml :

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item>
        <shape android:shape="rectangle" >
            <solid android:color="@color/colorPrimary" />
        </shape>
    </item>

    <item android:top="-2dp" android:right="-2dp" android:left="-2dp">
        <shape>
            <solid android:color="@android:color/transparent" />
            <stroke
                android:width="1dp"
                android:color="@color/titleBarBorder" />
        </shape>
    </item>

</layer-list>

and then i added this .xml to my cardview as a background using android:background="@drawable/toolbar_background" but the color just wont show up and cardview will render with a white background. what am i doing wrong ?

Femn Dharamshi
  • 527
  • 1
  • 9
  • 25

1 Answers1

0

I used an image view to set the background xml to card view :

<android.support.v7.widget.CardView
            android:layout_alignParentTop="true"
            android:layout_width="match_parent"
            android:layout_height="70dp"
            app:cardBackgroundColor="@color/colorPrimary"
            app:cardElevation="4dp"
            app:cardCornerRadius="0dp">

                <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:src="@drawable/toolbarbackground"
                    android:scaleType="fitXY"/>

                <cardview contents here>...

        </android.support.v7.widget.CardView>
Femn Dharamshi
  • 527
  • 1
  • 9
  • 25