I have a spinner set up with a custom popup menu. This popup menu has round corners. When you tap an option in the spinner, it shows the ripple background animation however the ripple goes outside the round corners and forms a normal rectangle. How can i make it so that the ripple stays within the boundaries of the round rectangle?
Popup background:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/primaryLight2"/>
<corners android:radius="4dp"/>
Spinner:
<Spinner
android:id="@+id/spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
android:layout_marginStart="4dp"
android:gravity="start|center_vertical"
android:popupBackground="@drawable/background_spinner_popup"
android:textColor="@color/primaryText"
android:textSize="18sp"/>
Dropdown item:
<TextView android:id="@android:id/text1"
style="@style/spinnerDropDownItemStyle"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:padding="8dp"
android:textSize="18sp"
android:background="@drawable/background_spinner_item_dropdown"
android:singleLine="true"
android:textColor="@color/white"/>
Dropdown item background:
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:colorControlHighlight">
<!-- Default background -->
<item>
<shape android:shape="rectangle">
<corners android:radius="4dp"/>
</shape>
</item>
<!-- Ripple bounds -->
<item android:id="@android:id/mask">
<shape android:shape="rectangle">
<corners android:radius="4dp"/>
</shape>
</item>
Setting up the spinner:
final Spinner spinner = (Spinner) rootView.findViewById(R.id.spinner);
ArrayAdapter arrayAdapter = ArrayAdapter.createFromResource(MainActivity.context, R.array.spinner, R.layout.item_spinner);
arrayAdapter.setDropDownViewResource(R.layout.item_spinner_dropdown);
spinner.setAdapter(arrayAdapter);
The items also seem to already have a ripple background by default, even if i remove the custom ripple background.