I'm trying to use cardview with my recyclerview. The recycler view works on its own. I've got it set up with databinding. But I wanted the recyclerview to look better which is why I'm wanting to use cardview with it.
This is my layout file for individual views:
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="individualEntry"
type="com.zebotek.balancedmindjournal.persistance.JournalEntryDataClass" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_gravity="center"
card_view:cardCornerRadius="4dp">
<TextView
android:id="@+id/dateTextBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="14sp"
app:dateStringFormatted="@{individualEntry}"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/journalEntryTextBox"
android:layout_width="match_parent"
android:layout_height="36dp"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:textSize="14sp"
app:journalEntryText="@{individualEntry}"
app:layout_constraintTop_toBottomOf="@+id/dateTextBox" />
</android.support.v7.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
and this is my dependencies:
cardView_version = '28.0.0'
implementation "com.android.support:cardview-v7:$cardView_version"
implementation "com.android.support:appcompat-v7:$cardView_version"
implementation "com.android.support:recyclerview-v7:$cardView_version"
I can't identify anything that I could do differently. I have minSdkVersion set at 21.
The code works just fine without the cardview. If I add the cardview, now it won't compile and I get that error. I've even tried placing the cardview above the constraintlayout. I've replaced the constraintlayout with the cardview and even replaced the top level layout with the cardview.
Try to use
androidx.cardview.widget.CardView
, instead ofandroid.support.v7.widget.CardView
.And add dependency: