Sever
Sever

Reputation: 2636

Android CardView And Eclipse ADT

I'm using Eclipse and have a trouble with CardView.

error: No resource identifier found for attribute 'cardCornerRadius' in package

I already add latest android-support-v7-cardview.jar to libs folder and build path.

My CardView layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context=".activity.CardViewActivity">

    <android.support.v7.widget.CardView
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:id="@+id/cardView"
        card_view:cardCornerRadius="6dp"
        card_view:cardBackgroundColor="#84ffff">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <TextView
                android:id="@+id/title_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Test CardView"
                android:layout_centerInParent="true"
                android:textSize="18sp"
                android:textColor="#fff"/>
        </RelativeLayout>
    </android.support.v7.widget.CardView>

</RelativeLayout>

Also target sdk version in manifest is targetSdkVersion="22".

But I still get same error.

Please, don't give me examples for Android Studio. It works fine in AS. But I don't use it for many reasons.

Upvotes: 2

Views: 877

Answers (2)

Sever
Sever

Reputation: 2636

Finally I found a solution. Instead of adding .jar file. You could import it as library.

Error inflating class and android.support.v7.widget.CardView

Upvotes: 1

hrskrs
hrskrs

Reputation: 4490

Try these (assuming you have have added v7 support library jar file to libs folder):

  • In the new library project, expand the libs folder, right-click .jar file and select Build > Path > Add to Build Path
  • Right-click the library project folder and select Build Path > Configure Build Path. In the Order and Export tab, check the .jar file you added to the build path, so it will be exported to project and Uncheck Android Dependencies

--

Other way to achieve that

Add this to styles:

<style name="CardViewStyle" parent="MyCardView">
     <item name="cardCornerRadius">6dp</item>
     <item name="cardBackgroundColor">#84ffff</item>
</style>

and set parent attribute of CardView to MyCardView

and remove these lines from xml:

card_view:cardCornerRadius="6dp"
card_view:cardBackgroundColor="#84ffff"

--

Also check if you have:

  • Latest Android SDK Tools, Platform-tools and Build-tools
  • Latest Android Support Library

Upvotes: 1

Related Questions