From 4e5ee906050f550759ad597e49ffebcc7c564a5a Mon Sep 17 00:00:00 2001 From: dtvv Date: Wed, 31 Oct 2018 15:25:36 -0600 Subject: [PATCH] QR code control --- .../utils/SquaredImageView.kt | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 app/src/main/java/cy/agorise/bitsybitshareswallet/utils/SquaredImageView.kt diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/SquaredImageView.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/SquaredImageView.kt new file mode 100644 index 0000000..8fd09e4 --- /dev/null +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/SquaredImageView.kt @@ -0,0 +1,30 @@ +package cy.agorise.crystalwallet.util + +import android.content.Context +import android.support.v7.widget.AppCompatImageView +import android.util.AttributeSet + +/** + * Created by xd on 1/24/18. + * ImageView which adjusts its size to always create a square + */ + +class SquaredImageView : AppCompatImageView { + constructor(context: Context) : super(context) {} + + constructor(context: Context, @Nullable attrs: AttributeSet) : super(context, attrs) {} + + constructor(context: Context, @Nullable attrs: AttributeSet, defStyleAttr: Int) : super( + context, + attrs, + defStyleAttr + ) { + } + + protected fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec) + + val size = Math.min(getMeasuredWidth(), getMeasuredHeight()) + setMeasuredDimension(size, size) + } +}