simplify the squareImageView creation

This commit is contained in:
tibbi 2017-09-15 23:22:33 +02:00
parent 6f3fd675e2
commit 8f8dd04920
1 changed files with 2 additions and 3 deletions

View File

@ -14,8 +14,7 @@ class MySquareImageView : ImageView {
constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle)
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
val spec = if (isVerticalScrolling) measuredWidth else measuredHeight
setMeasuredDimension(spec, spec)
val spec = if (isVerticalScrolling) widthMeasureSpec else heightMeasureSpec
super.onMeasure(spec, spec)
}
}