Last active
August 3, 2017 21:30
-
-
Save rodly/5db121f5926bf9544a054303ebb47d79 to your computer and use it in GitHub Desktop.
Useful Android view visibility extensions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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