I have a list of recipes in my database. Each recipe contains a title, and a list of ingredients like so:
This then needs to be properly displayed in an android device in a recyclerview. So far, in my activity_main.xml I have created a recyclerview:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:padding="20dp"
android:background="#f1f1f1"
android:gravity="center">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerViewRecipes"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
And the custom recyclerview list item looks like below:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="400dp"
android:layout_margin="20dp"
android:background="@drawable/cornered_background"
android:padding="20dp">
<TextView
android:id="@+id/tvRecipeTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:layout_centerHorizontal="true"
android:textStyle="bold"
android:textColor="@android:color/black">
<ImageView
android:id="@+id/imgDelete"
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@drawable/delete"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerViewIngredients"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:minHeight="100dp"
android:layout_below="@id/tvRecipeTitle">
</android.support.v7.widget.RecyclerView>
<ImageView
android:id="@+id/imgEdit"
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@drawable/edit"
android:layout_marginTop="20dp"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"/>
</RelativeLayout>
As you can see from the code above, I then have another recyclerview for the various ingredients inside each recipe item. I am convinced that this is not the right way to go about this. How would I efficiently display the list of ingredients inside each recyclerview item?