Forked from akshaykalola28/ViewVisibilityExtensions.kt
Created
March 20, 2023 04:09
-
-
Save e4basil/03dec962d1a8ed44878e5706a2141e10 to your computer and use it in GitHub Desktop.
Kotlin Extension functions for handling the view visibility in android
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