You can't directly apply border to rcyclerView. You put a LinearLayout fitting the parent RecyclerView Layout and set the border to that LinearLayout.
Define the border_line.xml in drawable:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<solid android:color="#F50057"/>
<corners android:radius="5dp"/>
</shape>
</item>
</selector>
And then apply it to child LinearLayout which is the child of RecyclerView like this:
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/border_line"
android:orientation="vertical">
</LinearLayout>
</android.support.v7.widget.CardView>
And you can change the border color in border_line.xml file.