Search code examples
androidkotlinmaterial-designandroid-animationandroid-transitions

Animate a ChoiceChips' background color on selector state change


I'm trying to achieve a choice chip group like shown in the material documentation:

Link to Animation Video

Currently, I'm just using a selector as a background drawable:

<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:color="?attr/colorAccent" android:state_enabled="true" android:state_selected="true" />
    <item android:color="@color/md_white_1000" />

</selector>

Switching those colors given above shall be animated.

If possible, the animation/transition should be compatible to api 17.


Solution

  • Currently, this is only possible with a custom view.

    There's an open issue on MDC to implement animatable backgrounds: https://issuetracker.google.com/issues/130410732