Reputation: 1430
I have tried to change my framelayout to a CardView using the following tutorial, https://guides.codepath.com/android/Using-the-CardView.
Originally I had the code,
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/note_tile_margin">
<LinearLayout
android:id="@+id/tile_clickable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:background="@drawable/tile_selector"
android:clickable="true"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/noteTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_margin="@dimen/tile_padding"
android:layout_toLeftOf="@+id/btn_tile_expand"
android:ellipsize="end"
android:maxLines="@integer/max_tile_lines"
android:singleLine="false"
android:text="Write your message here... "
android:textColor="@color/tile_text" />
<LinearLayout
android:id="@+id/btn_tile_expand"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="@drawable/click_selector"
android:gravity="top" >
<ImageView
android:id="@+id/btn_tile_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="7dp"
android:src="@drawable/icon_dark_expand" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:id="@+id/tile_options"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:gravity="right"
android:visibility="gone" >
<ImageView
android:id="@+id/btn_tile_links"
style="@style/btn_tile_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:contentDescription="Hyperlinks"
android:src="@drawable/icon_dark_web" />
<ImageView
android:id="@+id/btn_tile_delete"
style="@style/btn_tile_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:contentDescription="@string/deleteNote"
android:src="@drawable/icon_dark_delete" />
<ImageView
android:id="@+id/btn_tile_share"
style="@style/btn_tile_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:contentDescription="@string/share"
android:src="@drawable/icon_dark_share" />
<ImageView
android:id="@+id/btn_tile_copy"
style="@style/btn_tile_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:contentDescription="Copy to clipboard"
android:src="@drawable/icon_dark_copy" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
then I followed the steps outlined in this tutorial and changed the bits it told me to. It seemed to be quite easy to follow the steps and the code is now,
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content>
<LinearLayout
android:id="@+id/tile_clickable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:background="@drawable/tile_selector"
android:clickable="true"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/noteTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_margin="@dimen/tile_padding"
android:layout_toLeftOf="@+id/btn_tile_expand"
android:ellipsize="end"
android:maxLines="@integer/max_tile_lines"
android:singleLine="false"
android:text="Write your message here... "
android:textColor="@color/tile_text" />
<LinearLayout
android:id="@+id/btn_tile_expand"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="@drawable/click_selector"
android:gravity="top" >
<ImageView
android:id="@+id/btn_tile_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="7dp"
android:src="@drawable/icon_dark_expand" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:id="@+id/tile_options"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:gravity="right"
android:visibility="gone" >
<ImageView
android:id="@+id/btn_tile_links"
style="@style/btn_tile_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:contentDescription="Hyperlinks"
android:src="@drawable/icon_dark_web" />
<ImageView
android:id="@+id/btn_tile_delete"
style="@style/btn_tile_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:contentDescription="@string/deleteNote"
android:src="@drawable/icon_dark_delete" />
<ImageView
android:id="@+id/btn_tile_share"
style="@style/btn_tile_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:contentDescription="@string/share"
android:src="@drawable/icon_dark_share" />
<ImageView
android:id="@+id/btn_tile_copy"
style="@style/btn_tile_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:contentDescription="Copy to clipboard"
android:src="@drawable/icon_dark_copy" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
I then go to build the project and get the following error message:
How can I implement this CardView layout properly and what is going wrong?
Note: This is linked to my last problem, Rounding the corners of views in notepad android app.
Upvotes: 0
Views: 207
Reputation: 2325
You missed quotation mark in layout_height="wrap_content":
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
Upvotes: 1