Android Studio Kotlin – TransitionDrawable to a radius button-ThrowExceptions

Exception or error:

I have a button with this background:

 <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
        <solid android:color="#FFFFFF"/>
        <corners android:radius="5dp"/>
        <stroke android:color="#E0E0E0"
            android:width="2dp"/>
    </shape>

When button is clicked it should change background color using TransitionDrawable:

val color = arrayOf<ColorDrawable>(ColorDrawable(Color.WHITE), ColorDrawable(getColor(R.color.myColor)))
val trans = TransitionDrawable(color)
quiz_rispsta_uno_button.background = trans
trans.startTransition(500)

But on button click the radius disappear

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *