1. Are you ready for the Galaxy S20? Here is everything we know so far!

xml error in Android Studio

Discussion in 'Android Development' started by brentc, Feb 1, 2022.

  1. brentc

    brentc Newbie
    Thread Starter

    I have this code. I get an error at <ImageView....The error message is Resource Linking Failed...Why?

    <?xml version="1.0" encoding="utf-8"?>
    <androidx.cardview.widget.CardView 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/parent"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="10dp"
    app:cardCornerRadius="10dp"
    app:cardElevation="10dp">

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

    <TextView
    android:id="@+id/txtName"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:text="Contact Name"
    android:textStyle="bold" />

    <TextView
    android:id="@+id/txtEmail"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/txtName"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="20dp"
    android:text="Contact Email"
    android:textStyle="italic"
    android:layout_marginStart="5dp"/>

    <ImageView
    android:id="@+id/image"
    android:layout_width="150dp"
    android:layout_height="150dp"
    android:layout_below="@id/txtEmail"
    android:layout_marginTop="60dp"
    android:centerHorizontal="true"
    android:src="@drawable/ic_launcher_background" />

    </RelativeLayout>
    </androidx.cardview.widget.CardView>
     


    #1 brentc, Feb 1, 2022
    Last edited: Feb 1, 2022
  2. Best Answer:
    Post #2 by brentc, Feb 1, 2022 (3 points)

    1. Download the Forums for Android™ app!


      Download

       
  3. brentc

    brentc Newbie
    Thread Starter

    Ok I got it! The line....

    android:centerHorizontal="true"

    was screwing it up.

    It should be
    android:layout_centerHorizontal="true"
     
    codesplice and mikedt like this.
Loading...
Similar Threads - xml error Android
  1. Jinxis
    Replies:
    4
    Views:
    382
  2. QuantumGnosis
    Replies:
    2
    Views:
    507
  3. pickled mango 702
    Replies:
    4
    Views:
    1,493
  4. catdog123555
    Replies:
    0
    Views:
    925
  5. ozth89
    Replies:
    2
    Views:
    2,746
  6. FlipperTime
    Replies:
    0
    Views:
    1,060
  7. FlipperTime
    Replies:
    0
    Views:
    1,045
  8. batboy
    Replies:
    7
    Views:
    4,917
  9. Thomas Thorton
    Replies:
    0
    Views:
    1,644
  10. Gleis
    Replies:
    1
    Views:
    2,331

Share This Page

Loading...