Skip to content

Instantly share code, notes, and snippets.

@nickbutcher
Created July 24, 2019 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickbutcher/2494afed45cc084be4642b9b47ee43f3 to your computer and use it in GitHub Desktop.
Save nickbutcher/2494afed45cc084be4642b9b47ee43f3 to your computer and use it in GitHub Desktop.
/* Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
- val anim = ObjectAnimator.ofFloat(view, View.ALPHA, targetAlpha)
- if (!visible) {
- anim.doOnEnd { view.visibility = View.GONE }
- }
+ val anim = view.animate().alpha(targetAlpha)
+ if (!visible) {
+ anim.withEndAction { view.visibility = View.GONE }
+ }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment