Skip to content

Instantly share code, notes, and snippets.

@erdemtopak
Created July 9, 2019 08:45
Show Gist options
  • Save erdemtopak/e966e94dbd7d859469788fc9fd7e1e3d to your computer and use it in GitHub Desktop.
Save erdemtopak/e966e94dbd7d859469788fc9fd7e1e3d to your computer and use it in GitHub Desktop.
Drawable Transition animation
/*
** res/drawable/transition_background.xml **
<transition xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/shape_selection_label_background_gray" />
<item android:drawable="@drawable/shape_selection_label_background_blue" />
</transition>
** layout file **
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/transition_background"/>
*/
// Usage
val transition = textView.background as Transition
transition.startTransition(300)
transition.reverseTransition(300)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment