aboutsummaryrefslogtreecommitdiff
path: root/core-ui/src/main/kotlin/ca/allanwang/kau/ui/views/MeasuredImageView.kt
diff options
context:
space:
mode:
Diffstat (limited to 'core-ui/src/main/kotlin/ca/allanwang/kau/ui/views/MeasuredImageView.kt')
-rw-r--r--core-ui/src/main/kotlin/ca/allanwang/kau/ui/views/MeasuredImageView.kt23
1 files changed, 23 insertions, 0 deletions
diff --git a/core-ui/src/main/kotlin/ca/allanwang/kau/ui/views/MeasuredImageView.kt b/core-ui/src/main/kotlin/ca/allanwang/kau/ui/views/MeasuredImageView.kt
new file mode 100644
index 0000000..2627d13
--- /dev/null
+++ b/core-ui/src/main/kotlin/ca/allanwang/kau/ui/views/MeasuredImageView.kt
@@ -0,0 +1,23 @@
+package ca.allanwang.kau.ui.views
+
+import android.content.Context
+import android.util.AttributeSet
+import android.widget.ImageView
+
+/**
+ * Created by Allan Wang on 2017-07-14.
+ */
+class MeasuredImageView @JvmOverloads constructor(
+ context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0, defStyleRes: Int = 0
+) : ImageView(context, attrs, defStyleAttr, defStyleRes), MeasureSpecContract by MeasureSpecDelegate() {
+
+ init {
+ initAttrs(context, attrs)
+ }
+
+ override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
+ val result = onMeasure(this, widthMeasureSpec, heightMeasureSpec)
+ super.onMeasure(result.first, result.second)
+ }
+
+} \ No newline at end of file