Using android.support.v7.widget.CardView in my project (Eclipse)
I'd like to use the new CardView widget that was introduced with the new Android L Developer Preview Support Library (As mentioned here), which seems to be part of a new revision of the v7 support library.
I have now updated my SDK version, downloaded the newest Support Library package, but I still cannot find the new CardView widget.
I already searched the web and the official docs, but could not get any hints on where I can get the new support library.
Any help is highly appreciated!
EDIT: I'm using ADT/Eclipse
Using Gradle or Android Studio, try adding a dependency on com.android.support:cardview-v7
.
There does not seem to be a regular Android library project at this time for cardview-v7
, leanback-v17
, palette-v7
, or recyclerview-v7
. I have no idea if/when Google will ship such library projects.
I finally found a way to use CardView in ADT/Eclipse. It's actually pretty easy:
- Create a new project in Android Studio
- Add the CardView dependency as explained in the other answers to this question
- Open ADT and create a new library project with package name
android.support.v7.cardview
- Delete all resources ADT auto-created
- Find the
exploded-aar
folder in Android Studio and copy the following files to these locations:- res/values/values.xml to the same location in your ADT project
- classes.jar to libs/ in your ADT project
-
AndroidManifest.xml use it to replace the auto-generated manifest in ADT
- Add classes.jar to the build path and make sure it's exported
- Add a reference to the library project in the project you want to use CardView in. You can follow the steps provided under
Adding libraries with resources
here: https://developer.android.com/tools/support-library/setup.html
As an alternative to having to create a new Android Studio project in order to get the AAR's content, you could also simply find and unzip the AAR from the local maven repo. Just follow the steps provided by Andrew Chen below.
Please note the CardView library might not be available in source- and ADT-compatible-form because it's still only a preview and a WIP. As there might be bug fixes and improvements in following releases, it's important to keep the library up-to-date, which is easy using the Gradle dependency, but must be done manually when using the steps provided above.