Home > Mobile >  Relative Layout not working inside Material Card View. Can not close Relative Layout Tag
Relative Layout not working inside Material Card View. Can not close Relative Layout Tag

Time:08-15

Hi im new to Android/XML I'm trying to create Relative layout inside material card view but the relative layout closing tag giving me error "Wrong way to Close this Tag" and says replace Material Card View with Relative Layout.

    <?xml version="1.0" encoding="utf-8"?>

<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@ id/parent">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        <ImageView
            android:layout_width="120dp"
            android:layout_height="170dp"
            android:id="@ id/bookimg"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="10dp"
            android:src="@mipmap/ic_launcher"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@ id/booktitle"
            android:text="Book Title"
            android:textSize="20sp"
            android:textColor="@color/white"
            android:textStyle="bold"/>


        </RelativeLayout>


</com.google.android.material.card.MaterialCardView>

CodePudding user response:

It must be like this

<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@ id/parent">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <ImageView
            android:layout_width="120dp"
            android:layout_height="170dp"
            android:id="@ id/bookimg"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="10dp"
            android:src="@mipmap/ic_launcher"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@ id/booktitle"
            android:text="Book Title"
            android:textSize="20sp"
            android:textColor="@color/white"
            android:textStyle="bold"/>


        </RelativeLayout>


</com.google.android.material.card.MaterialCardView>
  • Related