aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2020-01-19 21:46:16 -0800
committerGitHub <noreply@github.com>2020-01-19 21:46:16 -0800
commit7e88af5bdfe5fa7da793383045f71b702c38ba1f (patch)
tree921160e0468a37d19129c47626093e1d557ebc71
parentb7fd1c5c7e848d7cf12c49a1e9e319d4e11d0b5c (diff)
parent7bb55f260763f19f1f651e61711c0f171148c1c0 (diff)
downloadkau-7e88af5bdfe5fa7da793383045f71b702c38ba1f.tar.gz
kau-7e88af5bdfe5fa7da793383045f71b702c38ba1f.tar.bz2
kau-7e88af5bdfe5fa7da793383045f71b702c38ba1f.zip
Merge pull request #242 from AllanWang/misc
Misc
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt9
1 files changed, 9 insertions, 0 deletions
diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt
index 4757a00..556c01c 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt
@@ -88,6 +88,15 @@ inline val View.isInvisible: Boolean
inline val View.isGone: Boolean
get() = visibility == View.GONE
+/**
+ * Measure the height of a view if it had match_parent for width and no height restrictions
+ */
+inline val View.unboundedHeight: Int
+ get() {
+ measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED)
+ return measuredHeight
+ }
+
@KauUtils
inline fun View.setBackgroundColorRes(@ColorRes color: Int) =
setBackgroundColor(context.color(color))