Use below layout as item of your RecyclerView
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="15dp"
app:cardMaxElevation="3dp"
android:elevation="3dp"
app:cardUseCompatPadding="true"
app:cardBackgroundColor="@android:color/white">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_weight=".95"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="15dp">
<TextView
android:id="@+id/tv_received_message_heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Received Message:"/>
<TextView
android:id="@+id/tv_received_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="First Received Message"
android:layout_marginStart="5dp"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/colorPrimary"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="15dp">
<TextView
android:id="@+id/tv_reply_message_heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Reply Message:"/>
<TextView
android:id="@+id/tv_reply_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="First Reply Message"
android:layout_marginStart="5dp"/>
</LinearLayout>
</LinearLayout>
<View
android:layout_weight=".05"
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="@color/colorPrimary"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
Add your color in background
attribute of View
The Output of above code is:
I hope it works for you.
solved Make a similar layout like the one below