aboutsummaryrefslogtreecommitdiff
path: root/core-ui/src/main/kotlin/ca/allanwang/kau/ui/views/MeasuredImageView.kt
blob: 5cb43295bdbfb2e4709a069cf06e002b1749aa56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package ca.allanwang.kau.ui.views

import android.content.Context
import androidx.appcompat.widget.AppCompatImageView
import android.util.AttributeSet

/**
 * Created by Allan Wang on 2017-07-14.
 */
class MeasuredImageView @JvmOverloads constructor(
        context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : AppCompatImageView(context, attrs, defStyleAttr), 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)
    }

}