Reputation: 43
Im using Android Studio 3 with AppCompat It doesnt compile with this 3 labels:
card_view:cardCornerRadius="6dp"
card_view:cardElevation="10dp"
card_view:cardUseCompatPadding="true"
Here is my XML code i do not know what it could be wrong in my dependencies i do have the AppCompat and the CardView:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.valenzuela.salvador.apuebacalculo.MainActivity">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="200dp"
card_view:cardCornerRadius="6dp"
card_view:cardElevation="10dp"
card_view:cardUseCompatPadding="true" >
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/diferencial"
android:scaleType="centerCrop"/>
<TextView
android:id="@+id/txt2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Calculo Diferencial"
android:layout_gravity="bottom"
android:background="#8c000000"
android:textColor="#ffe3e3e3"
android:textSize="30sp"
android:textStyle="bold"/>
</android.support.v7.widget.CardView>
</android.support.constraint.ConstraintLayout>
Upvotes: 0
Views: 156
Reputation: 9225
Try adding this
xmlns:card_view="http://schemas.android.com/apk/res-auto"
in your code
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto" <--add this line -->
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.valenzuela.salvador.apuebacalculo.MainActivity">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="200dp"
card_view:cardCornerRadius="6dp"
card_view:cardElevation="10dp"
card_view:cardUseCompatPadding="true" >
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/diferencial"
android:scaleType="centerCrop"/>
<TextView
android:id="@+id/txt2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Calculo Diferencial"
android:layout_gravity="bottom"
android:background="#8c000000"
android:textColor="#ffe3e3e3"
android:textSize="30sp"
android:textStyle="bold"/>
</android.support.v7.widget.CardView>
</android.support.constraint.ConstraintLayout>
Upvotes: 0
Reputation: 54204
You're declaring the "auto" namespace on this line:
xmlns:app="http://schemas.android.com/apk/res-auto"
But you're trying to use it like this:
card_view:cardCornerRadius="6dp"
card_view:cardElevation="10dp"
card_view:cardUseCompatPadding="true"
It doesn't matter which of these two you change, but they have to match. So you either need xmlns:card_view
or app:cardCornerRadius
etc. I recommend using the app
name; that's standard practice.
Upvotes: 1