sara2011
sara2011

Reputation: 11

How to use card view in drawable resource file?

I am using Android Studio 4.1.1. I can use card view in an empty activity XML file. But I can not use card view in a drawable resource file. Anyone can please help me?

Also, I included the dependencies as following.

implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation "androidx.cardview:cardview:1.0.0"

Upvotes: 1

Views: 324

Answers (2)

Irine B Thayil
Irine B Thayil

Reputation: 11

You wont be able to use cardview in drawable. If you are looking to use it to set as a background for a view, create an xml file in layout and use the file as the background.

Upvotes: 0

Shikhar Deep
Shikhar Deep

Reputation: 252

You can't use CardView in drawables. CardView as the name suggests is a View. Drawable is a resource. Can you post more what you are hoping to achieve by including CardView in Drawable? I may be able to suggest an alternative way to achieve the desired result.

Upvotes: 1

Related Questions