Created
March 21, 2023 21:09
-
-
Save NikCapko/07e35b031553d4e276cfb7b38cadd803 to your computer and use it in GitHub Desktop.
Change view visibility
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 | |
fun View.gone() = run { visibility = View.GONE } | |
fun View.visible() = run { visibility = View.VISIBLE } | |
fun View.invisible() = run { visibility = View.INVISIBLE } | |
infix fun View.visibleIf(condition: Boolean) = | |
run { visibility = if (condition) View.VISIBLE else View.GONE } | |
infix fun View.goneIf(condition: Boolean) = | |
run { visibility = if (condition) View.GONE else View.VISIBLE } | |
infix fun View.invisibleIf(condition: Boolean) = | |
run { visibility = if (condition) View.INVISIBLE else View.VISIBLE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment