I am using a horizontal RecyclerView:
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:id="@+id/chronology_rv_players"/>
which contains several of the following CardViews:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.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:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_margin="3dp"
app:cardCornerRadius="10dp"
app:cardBackgroundColor="@android:color/transparent"
app:cardElevation="0dp"
app:cardMaxElevation="0dp"
android:padding="0dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal"
android:padding="0dp">
...
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="0dp">
<ImageView
android:id="@+id/iv_player_list_right"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/background_player_right"
android:scaleType="fitXY"
android:padding="0dp"/>
...
</RelativeLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
The drawable "background_player_right" is the following 9-patch image:
However, the 9-patch image does not stretch until the right end of the CardView image:
I think this is due to the fact that I am using an horizontal RecyclerView (similarly I was not able to align text to the right of a CardView) but I don't know how obtain the expected results.
Do you have any idea?
Skip the ImageView and set the 9 patch directly to the background of your RelativeLayout.