You should add an id to items to access them via java/kotlin.
check this background XML file
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#e0e0e0">
<item android:id="@+id/fab_shape">
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="25dp" />
<solid android:color="@color/colorAccent" />
</shape>
</item>
</ripple>
to change the solid color of this, on constraintLayout background, this drawable XML is applied
val background = constraintLayout.background as RippleDrawable
val bgShape = background.findDrawableByLayerId(R.id.fab_shape) as GradientDrawable
bgShape.color = color
for reference read this