I made an item XML file that I want to pass to an Adapter
so I can display a list of items within a RecyclerView.
The layout file consists of a CardView
which contains an ImageView
to show a movie poster and a TextView
to display the movie title.
My problem is that I can't find a way to place the TextView
over the ImageView
so the title can be seen above the poster.
my xml file:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/dimension_value_10"
>
<android.support.v7.widget.CardView
app:cardCornerRadius="@dimen/dimension_value_5"
android:layout_width="match_parent"
android:layout_height="200dp"
android:elevation="@dimen/dimension_value_15"
android:id="@+id/movie_poster_card"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true">
<ImageView
android:id="@id/movie_poster_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="10dp" />
<TextView
android:id="@+id/movie_title_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/movie_poster_card"
android:layout_centerHorizontal="true"
android:gravity="center|start"
android:layout_margin="@dimen/dimension_value_10"
android:paddingLeft="@dimen/dimension_value_10"
android:text="Movie title here"
android:textColor="@color/white"
android:layout_gravity="bottom"
android:textSize="26sp" />
</android.support.v7.widget.CardView>
Here is the design image to be more explicit: