1

when i add an image to the card view i am geting error like Error:(34) No resource identifier found for attribute 'srcCompat' in package 'com.hackerinside.jaisonjoseph.radioplanet'

this is my content_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:id="@+id/Relative"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_blue_dark"

app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.hackerinside.jaisonjoseph.radioplanet.MainActivity"
tools:showIn="@layout/activity_main">


<Button
    android:text="Button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/button"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true" />

<android.support.v7.widget.CardView
    android:layout_width="350dp"
    android:layout_height="200dp"
    app:cardElevation="10dp"
    android:id="@+id/card"
    android:layout_above="@+id/button"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="15dp"
    android:layout_marginTop="20dp">


    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:srcCompat="@mipmap/ic_launcher"
        android:id="@+id/imageView" />
</android.support.v7.widget.CardView>

Jaison_Joseph
  • 333
  • 7
  • 26

1 Answers1

2

Avoid using srcCompat, srcCompat attribute is actually defined within AppCompat library:

Replace this:

app:srcCompat="@mipmap/ic_launcher"

With this:

android:src="@mipmap/ic_launcher"
W4R10CK
  • 5,502
  • 2
  • 19
  • 30
  • 1
    not working giving error like Unexpected namespace prefix "app" found for tag ImageView less... (Ctrl+F1) Most Android views have attributes in the Android namespace. When referencing these attributes you must include the namespace prefix, or your attribute will be interpreted by aapt as just a custom attribute. Similarly, in manifest files, nearly all attributes should be in the android: namespace. – Jaison_Joseph Feb 02 '17 at 09:17
  • If i use wrap content or match parent , i am not able to adjust it – Jaison_Joseph Feb 02 '17 at 09:22
  • 1
    @Jaison_Joseph yo joseph bro do you need an upvote :O – Charuක Feb 02 '17 at 09:31
  • 1
    Questions which has complex logic and spending time to find logic are worth upvotes @Charuක. Am I correct Man ? :) :D – W4R10CK Feb 02 '17 at 09:33
  • 1
    hehe yes any way today is my bonus day ill give you both ;)) – Charuක Feb 02 '17 at 09:34
  • 1
    @Jaison_Joseph Thanks to Charuka. hahaha – W4R10CK Feb 02 '17 at 09:35
  • What u want in this layout, Ask what you want to achieve ? – W4R10CK Feb 02 '17 at 09:39