Skip to content

Instantly share code, notes, and snippets.

@rafali
Last active September 16, 2017 09:51
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafali/5146795 to your computer and use it in GitHub Desktop.
Save rafali/5146795 to your computer and use it in GitHub Desktop.
Background transition on Android
TransitionDrawable transition = (TransitionDrawable) view.getBackground();
if (toggle) {
view.startTransition(1200);
} else {
view.reverseTransition(1200);
}
android:background="@drawable/transition_drawable"
<?xml version="1.0" encoding="UTF-8"?>
<transition xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- The drawables used here can be solid colors, gradients, shapes, images, etc. -->
<item android:drawable="@drawable/selector_button"/>
<item android:drawable="@drawable/selector_button_off"/>
</transition>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment