Here's my view:
<FrameLayout 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="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_rounded"
android:backgroundTint="@color/view_primary_color"
android:elevation="4dp"
android:foregroundTint="@android:color/white">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/tvTitle"
style="@style/Header4.Semibold16.White"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:gravity="center"
android:text="Add to cart"
android:textAllCaps="false"
app:tint="@android:color/white"
tools:ignore="ContentDescription" />
<ProgressBar
android:id="@+id/pbLoading"
style="?android:attr/progressBarStyleSmall"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:visibility="gone" />
</FrameLayout>
And here's @color/view_primary_color
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/colorPrimary" android:state_enabled="true" />
<item android:color="@color/colorPrimaryDisabled" android:state_enabled="false" />
</selector>
When view's state is enabled
it's color is colorPrimary
.
When state is disabled
view's color is colorPrimaryDisabled
which is almost the same as colorPrimary
but only with 20% of alpha.
Here's how my view looks like is idle (enabled) state.
But when I click on the view it became like this.
View supposed to just change it's color to slightly translucent, but for some reason there's some shadow inside it.
If I use non-translucent color everything is ok. Or if I remove elevation
from the view everything is ok as well.
Feels like this is some kind of bug. Do you have any idea what is this?
Thanks!