Skip to content

Instantly share code, notes, and snippets.

@rodly
Last active August 3, 2017 21:30
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 rodly/5db121f5926bf9544a054303ebb47d79 to your computer and use it in GitHub Desktop.
Save rodly/5db121f5926bf9544a054303ebb47d79 to your computer and use it in GitHub Desktop.
Useful Android view visibility extensions
import android.view.View
var View.isVisible: Boolean
get() = visibility == View.VISIBLE
set(value) {
visibility = if (value) {
View.VISIBLE
} else {
View.GONE
}
}
fun View.invisible() {
visibility = View.INVISIBLE
}
fun View.visible() {
visibility = View.VISIBLE
}
fun View.gone() {
visibility = View.GONE
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment