maksnurgazy
maksnurgazy

Reputation: 21

Android development. CardView not working?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:background="#F3F3F3F3"
    android:layout_height="wrap_content">

    <android.support.v7.widget.CardView
        xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:id="@+id/dersName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="10dp"
            android:layout_marginRight="10dp"/>

    </android.support.v7.widget.CardView>

</LinearLayout>

Unfortunately,ProjectTry has stopped

Also I added this code

implementation 'com.android.support:recyclerview-v7:28.0.0'
//noinspection GradleCompatible
implementation 'com.android.support:cardview-v7:28.0.0'

compilation was successfull but, it gives me Unfortunately ProjectTry has stopped How can i overcome this problem? When I type

Upvotes: 0

Views: 4070

Answers (3)

Nesar Khodayar
Nesar Khodayar

Reputation: 1

If your manifest file has a android:hardwareAccelerated="false" line, delete it.

see for details https://developer.android.com/guide/topics/graphics/hardware-accel.html?hl=ru

Upvotes: 0

Rahul Mishra
Rahul Mishra

Reputation: 109

I had the same issue after updating my library to androidX

implementation 'androidx.cardview:cardview:1.0.0'

To overcome this problem.

<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
    android:id="@+id/dersName"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="10dp"
    android:layout_marginTop="10dp"
    android:layout_marginRight="10dp"/>
</androidx.cardview.widget.CardView>

Upvotes: 3

Ajit singh
Ajit singh

Reputation: 31

Use this code

   <androidx.cardview.widget.CardView 
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        app:elevation="5dp">
    </androidx.cardview.widget.CardView>

Upvotes: 1

Related Questions