I have to create a card view like this:

I create the layout in Xml like this:
<androidx.cardview.widget.CardView
android:id="@+id/cardDevice"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="4dp"
android:layout_marginBottom="4dp"
app:cardBackgroundColor="?attr/colorSurface"
app:cardCornerRadius="20dp"
app:cardElevation="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="-5dp"
android:layout_marginBottom="-5dp"
android:alpha="0.4"
android:scaleType="centerCrop"
android:src="@drawable/gradiant_device"
app:layout_constraintBottom_toBottomOf="@+id/iconArea"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/iconArea"/>
<androidx.cardview.widget.CardView
android:id="@+id/iconArea"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_marginStart="4dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
app:cardBackgroundColor="?attr/backgroundColor"
app:cardCornerRadius="16dp"
app:cardElevation="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.cardview.widget.CardView
android:id="@+id/cardIcon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:clickable="true"
android:foreground="?attr/selectableItemBackgroundBorderless"
app:cardBackgroundColor="?attr/colorPrimary"
app:cardCornerRadius="14dp"
app:cardElevation="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/imgIcon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="12dp"
app:srcCompat="@drawable/ic_lamp_off"/>
</androidx.cardview.widget.CardView>
</androidx.cardview.widget.CardView>
<!-- Device Name and Status -->
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="@id/iconArea"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/iconArea"
app:layout_constraintTop_toTopOf="@id/iconArea">
<TextView
android:id="@+id/txt_lamp_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="Lamp"
android:textSize="16sp"
android:textStyle="bold"/>
<TextView
android:id="@+id/txt_device_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-4dp"
android:text="On"/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
My problem is to create that gradiant_device drawable for glowing that way Start from under the card and ends to the layout:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:centerX="0%"
android:centerY="50%"
android:endColor="?attr/colorSurface"
android:gradientRadius="200%p"
android:startColor="?attr/colorPrimary"
android:type="radial"/>
</shape>
I need that gradiant start from under the card in RTL layouts also (when icon card is at right > gradiant start at right not left!) ALL OTHER VIEWS GETS RTL & LTR BUT gradiantBackground NOT
I also try to create a RTL and LTR files for gradiant_device separated! But its only on in xml design preview and not work in Run: if help I SET the language with this code on app start:
private fun setLocale(localeToSet: String) {
val localeListToSet = LocaleList(Locale(localeToSet))
LocaleList.setDefault(localeListToSet)
resources.configuration.setLocales(localeListToSet)
createConfigurationContext(resources.configuration)
}